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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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
);
69 return ssprintf ( "$(%s)", s
.c_str() );
73 MingwModuleHandler::MingwModuleHandler (
74 const Module
& module_
)
81 MingwModuleHandler::~MingwModuleHandler()
86 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
92 MingwModuleHandler::SetMakefile ( FILE* f
)
98 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
103 /*static*/ const FileLocation
*
104 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
106 switch ( file
->directory
)
108 case SourceDirectory
:
110 case IntermediateDirectory
:
111 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
113 case OutputDirectory
:
114 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
116 case InstallDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
120 throw InvalidOperationException ( __FILE__
,
122 "Invalid directory %d.",
129 /* caller needs to delete the returned object */
131 MingwModuleHandler::GetTargetFilename (
132 const Module
& module
,
133 string_list
* pclean_files
)
135 FileLocation
*target
= new FileLocation ( *module
.output
);
138 string_list
& clean_files
= *pclean_files
;
139 CLEAN_FILE ( *target
);
144 /* caller needs to delete the returned object */
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 FileLocation
*target
= new FileLocation ( *module
.dependency
);
153 string_list
& clean_files
= *pclean_files
;
154 CLEAN_FILE ( *target
);
159 /* caller needs to delete the returned object */
161 MingwModuleHandler::InstanciateHandler (
162 const Module
& module
,
163 MingwBackend
* backend
)
165 MingwModuleHandler
* handler
;
166 switch ( module
.type
)
169 case HostStaticLibrary
:
176 case EmbeddedTypeLib
:
177 handler
= new MingwModuleHandler( module
);
180 handler
= new MingwBuildToolModuleHandler ( module
);
183 handler
= new MingwKernelModuleHandler ( module
);
186 handler
= new MingwNativeCUIModuleHandler ( module
);
189 handler
= new MingwWin32CUIModuleHandler ( module
);
193 handler
= new MingwWin32GUIModuleHandler ( module
);
197 handler
= new MingwKernelModeDLLModuleHandler ( module
);
200 handler
= new MingwNativeDLLModuleHandler ( module
);
203 handler
= new MingwWin32DLLModuleHandler ( module
);
206 handler
= new MingwWin32OCXModuleHandler ( module
);
208 case KernelModeDriver
:
209 handler
= new MingwKernelModeDriverModuleHandler ( module
);
212 handler
= new MingwBootLoaderModuleHandler ( module
);
215 handler
= new MingwBootSectorModuleHandler ( module
);
218 handler
= new MingwBootProgramModuleHandler ( module
);
221 handler
= new MingwIsoModuleHandler ( module
);
224 handler
= new MingwLiveIsoModuleHandler ( module
);
227 handler
= new MingwIsoModuleHandler ( module
);
230 handler
= new MingwLiveIsoModuleHandler ( module
);
233 handler
= new MingwTestModuleHandler ( module
);
236 handler
= new MingwAliasModuleHandler ( module
);
239 handler
= new MingwCabinetModuleHandler ( module
);
242 handler
= new MingwElfExecutableModuleHandler ( module
);
245 throw UnknownModuleTypeException (
246 module
.node
.location
,
254 MingwModuleHandler::GetWorkingDirectory () const
260 MingwModuleHandler::GetBasename ( const string
& filename
) const
262 size_t index
= filename
.find_last_of ( '.' );
263 if ( index
!= string::npos
)
264 return filename
.substr ( 0, index
);
269 MingwModuleHandler::GetExtraDependencies (
270 const FileLocation
*file
) const
272 string extension
= GetExtension ( *file
);
273 if ( extension
== ".idl" || extension
== ".IDL" )
275 const FileLocation
*header
;
276 switch ( module
.type
)
278 case RpcServer
: header
= GetRpcServerHeaderFilename ( file
); break;
279 case RpcClient
: header
= GetRpcClientHeaderFilename ( file
); break;
280 case RpcProxy
: header
= GetRpcProxyHeaderFilename ( file
); break;
281 case IdlHeader
: header
= GetIdlHeaderFilename ( file
); break;
282 default: header
= NULL
; break;
287 string dependencies
= backend
->GetFullName ( *header
);
289 return " " + dependencies
;
296 MingwModuleHandler::GetCompilationUnitDependencies (
297 const CompilationUnit
& compilationUnit
) const
299 if ( compilationUnit
.GetFiles ().size () <= 1 )
301 vector
<string
> sourceFiles
;
302 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
304 const File
& file
= *compilationUnit
.GetFiles ()[i
];
305 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
307 return string ( " " ) + v2s ( sourceFiles
, 10 );
310 /* caller needs to delete the returned object */
312 MingwModuleHandler::GetModuleArchiveFilename () const
314 if ( IsStaticLibrary ( module
) )
315 return GetTargetFilename ( module
, NULL
);
316 return new FileLocation ( IntermediateDirectory
,
317 module
.output
->relative_path
,
318 ReplaceExtension ( module
.name
, ".temp.a" ) );
322 MingwModuleHandler::ReferenceObjects (
323 const Module
& module
)
325 if ( module
.type
== ObjectLibrary
)
327 if ( module
.type
== RpcServer
)
329 if ( module
.type
== RpcClient
)
331 if ( module
.type
== RpcProxy
)
333 if ( module
.type
== IdlHeader
)
335 if ( module
.type
== MessageHeader
)
341 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
342 const FileLocation
& destination
)
347 "\t${cp} %s %s 1>$(NUL)\n",
348 backend
->GetFullName ( source
).c_str (),
349 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
353 MingwModuleHandler::GetImportLibraryDependency (
354 const Module
& importedModule
)
357 if ( ReferenceObjects ( importedModule
) )
359 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
362 dep
= GetTargetMacro ( importedModule
);
363 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
365 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
366 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
367 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
368 if ( GetExtension ( *objectFilename
) == ".h" )
369 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
370 else if ( GetExtension ( *objectFilename
) == ".rc" )
371 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
376 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
377 dep
= backend
->GetFullName ( *library_target
);
378 delete library_target
;
384 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
385 string_list
& targets
)
387 if ( dependencyModule
.invocations
.size () > 0 )
389 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
391 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
392 invoke
.GetTargets ( targets
);
396 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
400 MingwModuleHandler::GetModuleDependencies (
401 string_list
& dependencies
)
403 size_t iend
= module
.dependencies
.size ();
408 for ( size_t i
= 0; i
< iend
; i
++ )
410 const Dependency
& dependency
= *module
.dependencies
[i
];
411 const Module
& dependencyModule
= *dependency
.dependencyModule
;
412 GetTargets ( dependencyModule
,
415 vector
<FileLocation
> v
;
416 GetDefinitionDependencies ( v
);
418 for ( size_t i
= 0; i
< v
.size (); i
++ )
420 const FileLocation
& file
= v
[i
];
421 dependencies
.push_back ( backend
->GetFullName ( file
) );
425 /* caller needs to delete the returned object */
427 MingwModuleHandler::GetObjectFilename (
428 const FileLocation
* sourceFile
,
429 const Module
& module
) const
431 DirectoryLocation destination_directory
;
433 string extension
= GetExtension ( *sourceFile
);
435 if ( module
.type
== BootSector
)
436 return new FileLocation ( *module
.output
);
437 else if ( extension
== ".rc" || extension
== ".RC" )
438 newExtension
= "_" + module
.name
+ ".coff";
439 else if ( extension
== ".mc" || extension
== ".MC" )
440 newExtension
= ".rc";
441 else if ( extension
== ".spec" || extension
== ".SPEC" )
442 newExtension
= ".stubs.o";
443 else if ( extension
== ".idl" || extension
== ".IDL" )
445 if ( module
.type
== RpcServer
)
446 newExtension
= "_s.o";
447 else if ( module
.type
== RpcClient
)
448 newExtension
= "_c.o";
449 else if ( module
.type
== RpcProxy
)
450 newExtension
= "_p.o";
455 newExtension
= "_" + module
.name
+ ".o";
457 if ( module
.type
== BootSector
)
458 destination_directory
= OutputDirectory
;
460 destination_directory
= IntermediateDirectory
;
462 const FileLocation
*obj_file
= new FileLocation(
463 destination_directory
,
464 sourceFile
->relative_path
,
465 ReplaceExtension ( sourceFile
->name
, newExtension
) );
466 PassThruCacheDirectory ( obj_file
);
472 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
474 return module
.name
+ "_clean";
478 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
480 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
482 Library
& library
= *module
.non_if_data
.libraries
[i
];
483 if ( library
.importedModule
->type
== ObjectLibrary
)
484 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
489 MingwModuleHandler::GenerateCleanTarget () const
491 if ( module
.type
== Alias
)
495 ".PHONY: %s_clean\n",
496 module
.name
.c_str() );
497 vector
<string
> referencedModuleNames
;
498 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
501 GetModuleCleanTarget ( module
).c_str(),
502 v2s ( referencedModuleNames
, 10 ).c_str () );
503 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
505 if ( ( i
+ 1 ) % 10 == 9 )
506 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
507 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
509 fprintf ( fMakefile
, " 2>$(NUL)\n" );
511 if( ProxyMakefile::GenerateProxyMakefile(module
) )
513 DirectoryLocation root
;
515 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
516 root
= SourceDirectory
;
518 root
= OutputDirectory
;
520 FileLocation
proxyMakefile ( root
,
521 module
.output
->relative_path
,
523 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
524 backend
->GetFullName ( proxyMakefile
).c_str () );
527 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
531 MingwModuleHandler::GenerateInstallTarget () const
533 if ( !module
.install
)
535 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
538 module
.name
.c_str (),
539 backend
->GetFullName ( *module
.install
).c_str () );
543 MingwModuleHandler::GenerateDependsTarget () const
546 ".PHONY: %s_depends\n",
547 module
.name
.c_str() );
549 "%s_depends: $(RBUILD_TARGET)\n",
550 module
.name
.c_str () );
552 "\t$(ECHO_RBUILD)\n" );
554 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
555 module
.name
.c_str () );
559 MingwModuleHandler::GetObjectFilenames ()
561 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
562 if ( compilationUnits
.size () == 0 )
565 string
objectFilenames ( "" );
566 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
568 if ( objectFilenames
.size () > 0 )
569 objectFilenames
+= " ";
570 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
571 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
572 objectFilenames
+= backend
->GetFullName ( *object_file
);
575 return objectFilenames
;
579 MingwModuleHandler::GenerateGccDefineParametersFromVector (
580 const vector
<Define
*>& defines
,
581 set
<string
>& used_defs
)
585 for ( size_t i
= 0; i
< defines
.size (); i
++ )
587 Define
& define
= *defines
[i
];
588 if (used_defs
.find(define
.name
) != used_defs
.end())
590 if (parameters
.length () > 0)
592 if (define
.name
.find('(') != string::npos
)
593 parameters
+= "$(QT)";
595 parameters
+= define
.name
;
596 if (define
.value
.length () > 0)
599 parameters
+= define
.value
;
601 if (define
.name
.find('(') != string::npos
)
602 parameters
+= "$(QT)";
603 used_defs
.insert(used_defs
.begin(),define
.name
);
609 MingwModuleHandler::GenerateGccDefineParameters () const
611 set
<string
> used_defs
;
612 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
, used_defs
);
613 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
, used_defs
);
614 if ( s
.length () > 0 )
623 MingwModuleHandler::ConcatenatePaths (
625 const string
& path2
) const
627 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
629 if ( path1
[path1
.length ()] == cSep
)
630 return path1
+ path2
;
632 return path1
+ cSep
+ path2
;
636 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
638 string parameters
, path_prefix
;
639 for ( size_t i
= 0; i
< includes
.size (); i
++ )
641 Include
& include
= *includes
[i
];
642 if ( parameters
.length () > 0 )
644 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
650 MingwModuleHandler::GenerateGccIncludeParameters () const
652 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
653 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
654 if ( s
.length () > 0 )
663 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
666 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
668 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
669 if ( compilerFlag
.compiler
== type
)
670 parameters
+= " " + compilerFlag
.flag
;
676 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
679 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
681 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
682 if ( parameters
.length () > 0 )
684 parameters
+= linkerFlag
.flag
;
690 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
691 const vector
<Library
*>& libraries
)
693 string
dependencies ( "" );
695 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
697 if ( wrap_count
++ == 5 )
698 dependencies
+= " \\\n\t\t", wrap_count
= 0;
699 else if ( dependencies
.size () > 0 )
701 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
707 MingwModuleHandler::GenerateLinkerParameters () const
709 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
713 MingwModuleHandler::GenerateMacro (
714 const char* assignmentOperation
,
716 const IfableData
& data
,
717 set
<const Define
*> *used_defs
,
718 bool generatingCompilerMacro
)
721 bool generateAssignment
;
723 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
724 if ( generatingCompilerMacro
)
725 generateAssignment
|= data
.compilerFlags
.size () > 0;
726 if ( generateAssignment
)
731 assignmentOperation
);
734 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
739 backend
->GetFullPath ( *pchFilename
).c_str () );
743 if ( generatingCompilerMacro
)
745 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
746 if ( compilerParameters
.size () > 0 )
751 compilerParameters
.c_str () );
754 for ( i
= 0; i
< data
.includes
.size(); i
++ )
756 const Include
& include
= *data
.includes
[i
];
757 const FileLocation
* includeDirectory
= include
.directory
;
761 backend
->GetFullPath ( *includeDirectory
).c_str() );
763 for ( i
= 0; i
< data
.defines
.size(); i
++ )
765 const Define
& define
= *data
.defines
[i
];
768 set
<const Define
*>::const_iterator last_define
;
769 for (last_define
= used_defs
->begin ();
770 last_define
!= used_defs
->end ();
773 if ( (*last_define
)->name
!= define
.name
)
775 if ( !define
.overridable
)
777 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
779 "Invalid override of define '%s', already defined at %s",
780 define
.name
.c_str (),
781 define
.node
->location
.c_str () );
783 if ( backend
->configuration
.Verbose
)
784 printf("%s: Overriding '%s' already defined at %s\n",
785 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
786 define
.node
->location
.c_str () );
789 if ( last_define
!= used_defs
->end () )
795 define
.name
.c_str() );
796 if (define
.value
.length () > 0)
800 define
.value
.c_str() );
802 used_defs
->insert( used_defs
->begin (), &define
);
804 if ( generateAssignment
)
806 fprintf ( fMakefile
, "\n" );
811 MingwModuleHandler::GenerateMacros (
812 const char* assignmentOperation
,
813 const IfableData
& data
,
814 const vector
<LinkerFlag
*>* linkerFlags
,
815 set
<const Define
*>& used_defs
)
817 GenerateMacro ( assignmentOperation
,
822 GenerateMacro ( assignmentOperation
,
828 if ( linkerFlags
!= NULL
)
830 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
831 if ( linkerParameters
.size () > 0 )
836 linkerflagsMacro
.c_str (),
838 linkerParameters
.c_str() );
842 if ( data
.libraries
.size () > 0 )
844 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
845 if ( deps
.size () > 0 )
858 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
860 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
861 delete compilationUnits
[i
];
865 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
870 MingwModuleHandler::GenerateSourceMacros (
871 const IfableData
& data
)
875 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
876 vector
<const FileLocation
*> headers
;
877 if ( compilationUnits
.size () > 0 )
882 sourcesMacro
.c_str () );
883 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
885 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
886 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
890 ( i
%10 == 9 ? " \\\n\t" : " " ),
891 backend
->GetFullName ( compilationName
).c_str () );
893 fprintf ( fMakefile
, "\n" );
896 vector
<CompilationUnit
*> sourceCompilationUnits
;
897 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
898 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
900 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
904 sourcesMacro
.c_str(),
905 backend
->GetFullName ( compilationName
).c_str () );
907 CleanupCompilationUnitVector ( sourceCompilationUnits
);
911 MingwModuleHandler::GenerateObjectMacros (
912 const IfableData
& data
)
915 const char* assignmentOperation
= "=";
917 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
918 vector
<const FileLocation
*> headers
;
919 vector
<const FileLocation
*> mcheaders
;
920 vector
<const FileLocation
*> mcresources
;
921 if ( compilationUnits
.size () > 0 )
923 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
925 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
926 if ( compilationUnit
.IsFirstFile () )
928 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
929 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
932 objectsMacro
.c_str(),
933 backend
->GetFullName ( *object_file
).c_str () );
935 assignmentOperation
= "+=";
942 objectsMacro
.c_str (),
943 assignmentOperation
);
944 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
946 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
947 if ( !compilationUnit
.IsFirstFile () )
949 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
950 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
951 if ( GetExtension ( *objectFilename
) == ".h" )
952 headers
.push_back ( objectFilename
);
953 else if ( GetExtension ( *objectFilename
) == ".rc" )
955 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
956 mcheaders
.push_back ( headerFilename
);
957 mcresources
.push_back ( objectFilename
);
964 ( i
%10 == 9 ? " \\\n\t" : " " ),
965 backend
->GetFullName ( *objectFilename
).c_str () );
966 delete objectFilename
;
970 fprintf ( fMakefile
, "\n" );
972 if ( headers
.size () > 0 )
977 module
.name
.c_str (),
978 assignmentOperation
);
979 for ( i
= 0; i
< headers
.size (); i
++ )
984 ( i
%10 == 9 ? " \\\n\t" : " " ),
985 backend
->GetFullName ( *headers
[i
] ).c_str () );
988 fprintf ( fMakefile
, "\n" );
991 if ( mcheaders
.size () > 0 )
996 module
.name
.c_str (),
997 assignmentOperation
);
998 for ( i
= 0; i
< mcheaders
.size (); i
++ )
1003 ( i
%10 == 9 ? " \\\n\t" : " " ),
1004 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
1005 delete mcheaders
[i
];
1007 fprintf ( fMakefile
, "\n" );
1010 if ( mcresources
.size () > 0 )
1015 module
.name
.c_str (),
1016 assignmentOperation
);
1017 for ( i
= 0; i
< mcresources
.size (); i
++ )
1022 ( i
%10 == 9 ? " \\\n\t" : " " ),
1023 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
1024 delete mcresources
[i
];
1026 fprintf ( fMakefile
, "\n" );
1029 vector
<CompilationUnit
*> sourceCompilationUnits
;
1030 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1031 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1033 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1034 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1038 objectsMacro
.c_str(),
1039 backend
->GetFullName ( *object_file
).c_str () );
1042 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1045 /* caller needs to delete the returned object */
1047 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1049 if ( !module
.pch
|| !use_pch
)
1051 return new FileLocation ( IntermediateDirectory
,
1052 module
.pch
->file
->relative_path
,
1053 module
.pch
->file
->name
+ ".gch" );
1056 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1057 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1058 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1059 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1060 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1062 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1063 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1065 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1066 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1068 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1069 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1070 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1071 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1072 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1074 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1075 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1076 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1077 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1079 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1080 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1081 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1082 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1083 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1085 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1086 "\t$(Q)$(WRC_TARGET) ${$(module_name)_RCFLAGS} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp\n"
1087 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1088 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1089 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1090 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1091 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1092 Rule
wmcRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(WMC_TARGET) $(source) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1094 "\t$(Q)$(WMC_TARGET) -i -H $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h -o $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(source)\n",
1095 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1096 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1097 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1098 Rule
winebuildKMRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1099 "\t$(ECHO_WINEBLD)\n"
1100 "\t${gcc} -xc -E $(source) -I. > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
1101 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
1102 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c:\n"
1103 "\t${cp} $(NUL) $@ 1>$(NUL)\n"
1104 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1106 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1107 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
1108 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1109 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1110 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1111 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1112 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1113 "\t$(ECHO_WINEBLD)\n"
1114 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source)\n"
1115 "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1116 "\t$(ECHO_WINEBLD)\n"
1117 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c --pedll $(source_path)$(SEP)$(source_name_noext).spec\n"
1118 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1120 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1121 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1122 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1123 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1124 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1125 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1126 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1128 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1129 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1130 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1131 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1132 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1134 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h -s -S $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(source)\n"
1135 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1137 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1138 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1139 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1140 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1141 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1142 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1143 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1145 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h -c -C $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(source)\n"
1146 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1148 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1149 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1150 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1151 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1152 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1153 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1154 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1156 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h -p -P $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(source)\n"
1157 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1159 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1160 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1161 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1162 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1163 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1164 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1165 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1167 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1168 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1169 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1170 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1172 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1173 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1174 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1175 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1177 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1178 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1179 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1180 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1182 "\t${gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1183 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1184 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1185 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1187 "\t${host_gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1188 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1189 Rule
emptyRule ( "", NULL
);
1192 MingwModuleHandler::GenerateGccCommand (
1193 const FileLocation
* sourceFile
,
1195 const string
& extraDependencies
)
1197 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1198 string dependencies
= extraDependencies
;
1201 string extension
= GetExtension ( *sourceFile
);
1202 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1203 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1205 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1209 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1213 /* WIDL generated headers may be used */
1214 vector
<FileLocation
> rpcDependencies
;
1215 GetRpcHeaderDependencies ( rpcDependencies
);
1216 if ( rpcDependencies
.size () > 0 )
1217 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1219 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1223 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1225 for ( size_t i
= 0; i
< module
.project
.non_if_data
.properties
.size (); i
++ )
1227 const Property
& property
= *module
.project
.non_if_data
.properties
[i
];
1228 if ( property
.name
== name
)
1229 return property
.value
;
1231 return string ( "" );
1234 /* caller needs to delete the returned object */
1236 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1238 string newname
= GetBasename ( base
->name
) + "_s.h";
1239 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1242 /* caller needs to delete the returned object */
1244 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1246 string newname
= GetBasename ( base
->name
) + "_c.h";
1247 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1250 /* caller needs to delete the returned object */
1252 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1254 string newname
= GetBasename ( base
->name
) + "_p.h";
1255 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1258 /* caller needs to delete the returned object */
1260 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1262 string newname
= GetBasename ( base
->name
) + ".h";
1263 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1266 /* caller needs to delete the returned object */
1268 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1270 string newname
= GetBasename ( base
->name
) + ".h";
1271 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1275 MingwModuleHandler::GenerateCommands (
1276 const CompilationUnit
& compilationUnit
,
1277 const string
& extraDependencies
)
1279 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1280 string extension
= GetExtension ( sourceFile
);
1281 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1290 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1291 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1292 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1293 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1294 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1295 { HostFalse
, Kernel
, ".spec", &winebuildKMRule
},
1296 { HostFalse
, KernelModeDLL
, ".spec", &winebuildKMRule
},
1297 { HostDontCare
, TypeDontCare
, ".spec", &winebuildRule
},
1298 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1299 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1300 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1301 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1302 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1303 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1304 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1305 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1306 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1307 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1308 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1309 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1310 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1311 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1314 Rule
*customRule
= NULL
;
1316 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1318 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= module
.host
)
1320 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1322 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1324 customRule
= rules
[i
].rule
;
1328 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1330 GenerateGccCommand ( &sourceFile
,
1332 GetCompilationUnitDependencies ( compilationUnit
) + GetExtraDependencies ( &sourceFile
) + extraDependencies
);
1334 else if ( customRule
)
1335 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1338 throw InvalidOperationException ( __FILE__
,
1340 "Unsupported filename extension '%s' in file '%s'",
1342 backend
->GetFullName ( sourceFile
).c_str () );
1347 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1349 fprintf ( fMakefile
,
1350 "ifeq ($(ROS_BUILDMAP),full)\n" );
1352 FileLocation
mapFilename ( OutputDirectory
,
1353 module
.output
->relative_path
,
1354 GetBasename ( module
.output
->name
) + ".map" );
1355 CLEAN_FILE ( mapFilename
);
1357 fprintf ( fMakefile
,
1358 "\t$(ECHO_OBJDUMP)\n" );
1359 fprintf ( fMakefile
,
1360 "\t$(Q)${objdump} -d -S %s > %s\n",
1361 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1362 backend
->GetFullName ( mapFilename
).c_str () );
1364 fprintf ( fMakefile
,
1366 fprintf ( fMakefile
,
1367 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1369 fprintf ( fMakefile
,
1371 fprintf ( fMakefile
,
1372 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1373 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1374 backend
->GetFullName ( mapFilename
).c_str () );
1376 fprintf ( fMakefile
,
1379 fprintf ( fMakefile
,
1384 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1386 fprintf ( fMakefile
,
1387 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1389 FileLocation
nostripFilename ( OutputDirectory
,
1390 module
.output
->relative_path
,
1391 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1392 CLEAN_FILE ( nostripFilename
);
1394 OutputCopyCommand ( *module
.output
, nostripFilename
);
1396 fprintf ( fMakefile
,
1401 MergeStringVector ( const Backend
* backend
,
1402 const vector
<FileLocation
>& input
,
1403 vector
<string
>& output
)
1407 int wrap_count
= -1;
1408 for ( size_t i
= 0; i
< input
.size (); i
++ )
1410 if ( wrap_count
++ == wrap_at
)
1412 output
.push_back ( s
);
1416 else if ( s
.size () > 0)
1418 s
+= backend
->GetFullName ( input
[i
] );
1420 if ( s
.length () > 0 )
1421 output
.push_back ( s
);
1425 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1426 vector
<FileLocation
>& objectFiles
) const
1428 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1430 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1431 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1432 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1433 objectFiles
.push_back ( *object_file
);
1439 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1441 if ( backend
->configuration
.CleanAsYouGo
)
1443 vector
<FileLocation
> objectFiles
;
1444 GetObjectsVector ( module
.non_if_data
,
1446 vector
<string
> lines
;
1447 MergeStringVector ( backend
,
1450 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1452 fprintf ( fMakefile
,
1453 "\t-@${rm} %s 2>$(NUL)\n",
1454 lines
[i
].c_str () );
1460 MingwModuleHandler::GenerateRunRsymCode () const
1462 fprintf ( fMakefile
,
1463 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1464 fprintf ( fMakefile
,
1465 "\t$(ECHO_RSYM)\n" );
1466 fprintf ( fMakefile
,
1467 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1468 fprintf ( fMakefile
,
1473 MingwModuleHandler::GenerateRunStripCode () const
1475 fprintf ( fMakefile
,
1476 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1477 fprintf ( fMakefile
,
1478 "\t$(ECHO_STRIP)\n" );
1479 fprintf ( fMakefile
,
1480 "\t${strip} -s -x -X $@\n\n" );
1481 fprintf ( fMakefile
,
1486 MingwModuleHandler::GenerateLinkerCommand (
1487 const string
& dependencies
,
1488 const string
& linkerParameters
,
1489 const string
& pefixupParameters
)
1491 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1492 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1493 string linker
= "${ld}";
1494 string objectsMacro
= GetObjectsMacro ( module
);
1495 string libsMacro
= GetLibsMacro ();
1497 string
target_macro ( GetTargetMacro ( module
) );
1498 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1500 string linkerScriptArgument
;
1501 if ( module
.linkerScript
!= NULL
)
1502 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1504 linkerScriptArgument
= "";
1506 fprintf ( fMakefile
,
1507 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1508 target_macro
.c_str (),
1509 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1510 dependencies
.c_str (),
1511 target_folder
.c_str () );
1512 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1513 string
targetName ( module
.output
->name
);
1515 /* HACK: if we have C++ in kernel, link it with some user mode dlls (kernel32 + msvcrt) ... */
1516 static const string libsCppKernel
= " '$(shell ${TARGET_CC} -print-file-name=libkernel32.a)' '$(shell ${TARGET_CC} -print-file-name=libmsvcrt.a)'";
1518 if ( !module
.HasImportLibrary() )
1520 fprintf ( fMakefile
,
1521 "\t%s %s%s %s %s%s %s %s -o %s\n",
1523 linkerParameters
.c_str (),
1524 linkerScriptArgument
.c_str (),
1525 objectsMacro
.c_str (),
1526 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1527 module
.cplusplus
&& (module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
) ? libsCppKernel
.c_str () : "",
1529 GetLinkerMacro ().c_str (),
1530 target_macro
.c_str () );
1534 FileLocation
temp_exp ( TemporaryDirectory
,
1536 module
.name
+ ".temp.exp" );
1537 CLEAN_FILE ( temp_exp
);
1539 fprintf ( fMakefile
,
1540 "\t${dlltool} --dllname %s --def %s --output-exp %s%s%s\n",
1541 targetName
.c_str (),
1542 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1543 backend
->GetFullName ( temp_exp
).c_str (),
1544 module
.mangledSymbols
? "" : " --kill-at",
1545 module
.underscoreSymbols
? " --add-underscore" : "" );
1547 fprintf ( fMakefile
,
1548 "\t%s %s%s %s %s %s%s %s %s -o %s\n",
1550 linkerParameters
.c_str (),
1551 linkerScriptArgument
.c_str (),
1552 backend
->GetFullName ( temp_exp
).c_str (),
1553 objectsMacro
.c_str (),
1554 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1555 module
.cplusplus
&& (module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
) ? libsCppKernel
.c_str () : "",
1557 GetLinkerMacro ().c_str (),
1558 target_macro
.c_str () );
1560 fprintf ( fMakefile
,
1561 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1562 target_macro
.c_str (),
1563 pefixupParameters
.c_str() );
1565 fprintf ( fMakefile
,
1566 "\t-@${rm} %s 2>$(NUL)\n",
1567 backend
->GetFullName ( temp_exp
).c_str () );
1570 GenerateBuildMapCode ();
1571 GenerateBuildNonSymbolStrippedCode ();
1572 GenerateRunRsymCode ();
1573 GenerateRunStripCode ();
1574 GenerateCleanObjectsAsYouGoCode ();
1576 if ( definitionFilename
)
1577 delete definitionFilename
;
1582 MingwModuleHandler::GeneratePhonyTarget() const
1584 string
targetMacro ( GetTargetMacro ( module
) );
1585 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1587 fprintf ( fMakefile
,
1589 targetMacro
.c_str ());
1590 fprintf ( fMakefile
, "%s: | %s\n",
1591 targetMacro
.c_str (),
1592 backend
->GetFullPath ( *target_file
).c_str () );
1598 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1601 string moduleDependencies
;
1603 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1604 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1606 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1607 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1608 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1609 if ( GetExtension ( *objectFilename
) == ".h" )
1610 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1611 else if ( GetExtension ( *objectFilename
) == ".rc" )
1612 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1613 delete objectFilename
;
1616 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1618 GenerateCommands ( *compilationUnits
[i
],
1619 moduleDependencies
);
1620 fprintf ( fMakefile
,
1624 vector
<CompilationUnit
*> sourceCompilationUnits
;
1625 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1626 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1628 GenerateCommands ( *sourceCompilationUnits
[i
],
1629 moduleDependencies
);
1631 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1635 MingwModuleHandler::GenerateObjectFileTargets ()
1637 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1641 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1642 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1644 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1645 CLEAN_FILE ( *pchFilename
);
1646 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1647 /* WIDL generated headers may be used */
1648 vector
<FileLocation
> rpcDependencies
;
1649 GetRpcHeaderDependencies ( rpcDependencies
);
1650 if ( rpcDependencies
.size () > 0 )
1651 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1652 fprintf ( fMakefile
,
1654 backend
->GetFullName ( *pchFilename
).c_str(),
1655 dependencies
.c_str(),
1656 backend
->GetFullPath ( *pchFilename
).c_str() );
1657 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1658 fprintf ( fMakefile
,
1659 "\t%s -o %s %s -g %s\n\n",
1660 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1661 backend
->GetFullName ( *pchFilename
).c_str(),
1662 cflagsMacro
.c_str(),
1663 backend
->GetFullName ( baseHeaderFile
).c_str() );
1667 GenerateObjectFileTargets ( module
.non_if_data
);
1668 fprintf ( fMakefile
, "\n" );
1671 /* caller needs to delete the returned object */
1673 MingwModuleHandler::GenerateArchiveTarget ()
1675 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1676 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1678 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1680 if ( IsStaticLibrary ( module
) && definitionFilename
)
1682 fprintf ( fMakefile
,
1683 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1684 module
.importLibrary
->dllname
.c_str (),
1685 backend
->GetFullName ( *definitionFilename
).c_str (),
1686 module
.mangledSymbols
? "" : " --kill-at",
1687 module
.underscoreSymbols
? " --add-underscore" : "" );
1690 if ( definitionFilename
)
1691 delete definitionFilename
;
1693 if(module
.type
== HostStaticLibrary
)
1694 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1696 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1698 GenerateCleanObjectsAsYouGoCode ();
1700 fprintf ( fMakefile
, "\n" );
1702 return archiveFilename
;
1706 MingwModuleHandler::GetCFlagsMacro () const
1708 return ssprintf ( "$(%s_CFLAGS)",
1709 module
.name
.c_str () );
1713 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1715 return ssprintf ( "$(%s_OBJS)",
1716 module
.name
.c_str () );
1720 MingwModuleHandler::GetLinkingDependenciesMacro () const
1722 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1726 MingwModuleHandler::GetLibsMacro () const
1728 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1732 MingwModuleHandler::GetLinkerMacro () const
1734 return ssprintf ( "$(%s_LFLAGS)",
1735 module
.name
.c_str () );
1739 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1741 if ( ReferenceObjects ( module
) )
1742 return GetObjectsMacro ( module
);
1745 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1746 string target
= backend
->GetFullName ( *target_file
).c_str ();
1753 MingwModuleHandler::GenerateSourceMacro ()
1755 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1757 GenerateSourceMacros ( module
.non_if_data
);
1759 // future references to the macro will be to get its values
1760 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1764 MingwModuleHandler::GenerateObjectMacro ()
1766 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1768 GenerateObjectMacros ( module
.non_if_data
);
1770 // future references to the macro will be to get its values
1771 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1775 MingwModuleHandler::GenerateTargetMacro ()
1777 fprintf ( fMakefile
,
1779 GetTargetMacro ( module
, false ).c_str (),
1780 GetModuleTargets ( module
).c_str () );
1784 MingwModuleHandler::GetRpcHeaderDependencies (
1785 vector
<FileLocation
>& dependencies
) const
1787 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1789 Library
& library
= *module
.non_if_data
.libraries
[i
];
1790 if ( library
.importedModule
->type
== RpcServer
||
1791 library
.importedModule
->type
== RpcClient
||
1792 library
.importedModule
->type
== RpcProxy
||
1793 library
.importedModule
->type
== IdlHeader
)
1795 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1797 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1798 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1799 string extension
= GetExtension ( sourceFile
);
1800 if ( extension
== ".idl" || extension
== ".IDL" )
1802 string basename
= GetBasename ( sourceFile
.name
);
1803 if ( library
.importedModule
->type
== RpcServer
)
1805 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1806 dependencies
.push_back ( *header
);
1809 if ( library
.importedModule
->type
== RpcClient
)
1811 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1812 dependencies
.push_back ( *header
);
1815 if ( library
.importedModule
->type
== RpcProxy
)
1817 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1818 dependencies
.push_back ( *header
);
1821 if ( library
.importedModule
->type
== IdlHeader
)
1823 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1824 dependencies
.push_back ( *header
);
1834 MingwModuleHandler::GenerateOtherMacros ()
1836 set
<const Define
*> used_defs
;
1838 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1839 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1840 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1841 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1842 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1843 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1844 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1849 &module
.linkerFlags
,
1852 if ( module
.host
== HostFalse
)
1856 module
.project
.non_if_data
,
1861 vector
<FileLocation
> s
;
1862 if ( module
.importLibrary
)
1864 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
1865 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
1867 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1868 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1869 string extension
= GetExtension ( sourceFile
);
1870 if ( extension
== ".spec" || extension
== ".SPEC" )
1871 GetSpecObjectDependencies ( s
, &sourceFile
);
1874 if ( s
.size () > 0 )
1879 linkDepsMacro
.c_str() );
1880 for ( size_t i
= 0; i
< s
.size(); i
++ )
1881 fprintf ( fMakefile
,
1883 backend
->GetFullName ( s
[i
] ).c_str () );
1884 fprintf ( fMakefile
, "\n" );
1887 string globalCflags
= "";
1888 if ( module
.host
== HostFalse
)
1889 globalCflags
+= " $(PROJECT_CFLAGS)";
1891 globalCflags
+= " -Wall -Wpointer-arith -D__REACTOS__";
1892 globalCflags
+= " -g";
1893 if ( backend
->usePipe
)
1894 globalCflags
+= " -pipe";
1895 if ( !module
.allowWarnings
)
1896 globalCflags
+= " -Werror";
1897 if ( module
.host
== HostTrue
)
1899 if ( module
.cplusplus
)
1900 globalCflags
+= " $(HOST_CPPFLAGS)";
1902 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
1906 if ( module
.cplusplus
)
1908 // HACK: use host headers when building C++
1909 globalCflags
+= " $(HOST_CPPFLAGS)";
1912 globalCflags
+= " -nostdinc";
1915 // Always force disabling of sibling calls optimisation for GCC
1916 // (TODO: Move to version-specific once this bug is fixed in GCC)
1917 globalCflags
+= " -fno-optimize-sibling-calls";
1922 cflagsMacro
.c_str (),
1923 globalCflags
.c_str () );
1925 if ( module
.host
== HostFalse
)
1929 "%s += $(PROJECT_RCFLAGS)\n",
1930 windresflagsMacro
.c_str () );
1934 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
1935 widlflagsMacro
.c_str (),
1936 module
.output
->relative_path
.c_str () );
1940 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1941 module
.name
.c_str () );
1947 "%s_LFLAGS += $(HOST_LFLAGS)\n",
1948 module
.name
.c_str () );
1954 linkDepsMacro
.c_str (),
1955 libsMacro
.c_str () );
1957 string cflags
= TypeSpecificCFlags();
1958 if ( cflags
.size() > 0 )
1960 fprintf ( fMakefile
,
1962 cflagsMacro
.c_str (),
1966 string nasmflags
= TypeSpecificNasmFlags();
1967 if ( nasmflags
.size () > 0 )
1969 fprintf ( fMakefile
,
1971 nasmflagsMacro
.c_str (),
1972 nasmflags
.c_str () );
1975 string linkerflags
= TypeSpecificLinkerFlags();
1976 if ( linkerflags
.size() > 0 )
1978 fprintf ( fMakefile
,
1980 linkerflagsMacro
.c_str (),
1981 linkerflags
.c_str () );
1984 if ( IsStaticLibrary ( module
) && module
.isStartupLib
)
1986 fprintf ( fMakefile
,
1987 "%s += -Wno-main\n\n",
1988 cflagsMacro
.c_str () );
1991 fprintf ( fMakefile
, "\n\n" );
1993 // future references to the macros will be to get their values
1994 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1995 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1996 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2000 MingwModuleHandler::GenerateRules ()
2002 string targetMacro
= GetTargetMacro ( module
);
2003 //CLEAN_FILE ( targetMacro );
2004 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2006 // generate phony target for module name
2007 fprintf ( fMakefile
, ".PHONY: %s\n",
2008 module
.name
.c_str () );
2009 string dependencies
= GetTargetMacro ( module
);
2010 if ( module
.type
== Test
)
2011 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2012 fprintf ( fMakefile
, "%s: %s\n\n",
2013 module
.name
.c_str (),
2014 dependencies
.c_str () );
2015 if ( module
.type
== Test
)
2017 fprintf ( fMakefile
,
2019 targetMacro
.c_str ());
2022 if ( !ReferenceObjects ( module
) )
2024 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2028 GenerateObjectFileTargets ();
2032 MingwModuleHandler::GetInvocationDependencies (
2033 const Module
& module
,
2034 string_list
& dependencies
)
2036 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2038 Invoke
& invoke
= *module
.invocations
[i
];
2039 if ( invoke
.invokeModule
== &module
)
2040 /* Protect against circular dependencies */
2042 invoke
.GetTargets ( dependencies
);
2047 MingwModuleHandler::GenerateInvocations () const
2049 if ( module
.invocations
.size () == 0 )
2052 size_t iend
= module
.invocations
.size ();
2053 for ( size_t i
= 0; i
< iend
; i
++ )
2055 const Invoke
& invoke
= *module
.invocations
[i
];
2057 if ( invoke
.invokeModule
->type
!= BuildTool
)
2059 throw XMLInvalidBuildFileException (
2060 module
.node
.location
,
2061 "Only modules of type buildtool can be invoked." );
2064 string invokeTarget
= module
.GetInvocationTarget ( i
);
2065 string_list invoke_targets
;
2066 assert ( invoke_targets
.size() );
2067 invoke
.GetTargets ( invoke_targets
);
2068 fprintf ( fMakefile
,
2070 invokeTarget
.c_str () );
2071 fprintf ( fMakefile
,
2073 invokeTarget
.c_str () );
2074 size_t j
, jend
= invoke_targets
.size();
2075 for ( j
= 0; j
< jend
; j
++ )
2077 fprintf ( fMakefile
,
2079 invoke_targets
[i
].c_str () );
2081 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2082 for ( j
= 1; j
< jend
; j
++ )
2083 fprintf ( fMakefile
,
2085 invoke_targets
[i
].c_str () );
2086 fprintf ( fMakefile
,
2088 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2089 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2090 fprintf ( fMakefile
,
2092 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2093 invoke
.GetParameters ().c_str () );
2098 MingwModuleHandler::GetPreconditionDependenciesName () const
2100 return module
.name
+ "_precondition";
2104 MingwModuleHandler::GetDefaultDependencies (
2105 string_list
& dependencies
) const
2107 /* Avoid circular dependency */
2108 if ( module
.host
== HostTrue
)
2111 if (module
.name
!= "psdk" &&
2112 module
.name
!= "dxsdk")
2114 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2115 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2118 if (module
.name
!= "errcodes" &&
2119 module
.name
!= "bugcodes" &&
2120 module
.name
!= "ntstatus")
2122 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2123 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2124 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2127 ///* Check if any dependent library relies on the generated headers */
2128 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2130 // const Module& m = *module.project.modules[i];
2131 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2133 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2134 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2135 // string extension = GetExtension ( sourceFile );
2136 // if (extension == ".mc" || extension == ".MC" )
2138 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2139 // dependencies.push_back ( dependency );
2146 MingwModuleHandler::GeneratePreconditionDependencies ()
2148 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2149 string_list dependencies
;
2150 GetDefaultDependencies ( dependencies
);
2151 GetModuleDependencies ( dependencies
);
2153 GetInvocationDependencies ( module
, dependencies
);
2155 if ( dependencies
.size() )
2157 fprintf ( fMakefile
,
2159 preconditionDependenciesName
.c_str () );
2160 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2161 fprintf ( fMakefile
,
2163 dependencies
[i
].c_str () );
2164 fprintf ( fMakefile
, "\n\n" );
2167 fprintf ( fMakefile
, "\n" );
2171 MingwModuleHandler::IsWineModule () const
2173 if ( module
.importLibrary
== NULL
)
2176 size_t index
= module
.importLibrary
->source
->name
.rfind ( ".spec.def" );
2177 return ( index
!= string::npos
);
2180 /* caller needs to delete the returned object */
2182 MingwModuleHandler::GetDefinitionFilename () const
2184 if ( module
.importLibrary
== NULL
)
2187 DirectoryLocation directory
;
2188 if ( IsWineModule () )
2189 directory
= IntermediateDirectory
;
2191 directory
= SourceDirectory
;
2193 return new FileLocation ( directory
,
2194 module
.importLibrary
->source
->relative_path
,
2195 module
.importLibrary
->source
->name
);
2199 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2201 if ( module
.importLibrary
!= NULL
)
2203 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2204 const FileLocation
*defFilename
= GetDefinitionFilename ();
2205 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2207 vector
<FileLocation
> deps
;
2208 GetDefinitionDependencies ( deps
);
2210 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
2212 fprintf ( fMakefile
, "%s:",
2213 backend
->GetFullName ( *library_target
).c_str () );
2217 fprintf ( fMakefile
, " %s",
2218 backend
->GetFullName ( *defFilename
).c_str () );
2221 size_t i
, iend
= deps
.size();
2222 for ( i
= 0; i
< iend
; i
++ )
2223 fprintf ( fMakefile
, " %s",
2224 backend
->GetFullName ( deps
[i
] ).c_str () );
2226 fprintf ( fMakefile
, " | %s\n",
2227 backend
->GetFullPath ( *library_target
).c_str () );
2229 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2231 fprintf ( fMakefile
,
2232 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2233 module
.output
->name
.c_str (),
2234 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2236 backend
->GetFullName ( *library_target
).c_str (),
2237 module
.mangledSymbols
? "" : " --kill-at",
2238 module
.underscoreSymbols
? " --add-underscore" : "" );
2242 delete library_target
;
2247 MingwModuleHandler::GetSpecObjectDependencies (
2248 vector
<FileLocation
>& dependencies
,
2249 const FileLocation
*file
) const
2251 string basename
= GetBasename ( file
->name
);
2253 FileLocation
defDependency ( IntermediateDirectory
,
2254 file
->relative_path
,
2255 basename
+ ".spec.def" );
2256 dependencies
.push_back ( defDependency
);
2258 FileLocation
stubsDependency ( IntermediateDirectory
,
2259 file
->relative_path
,
2260 basename
+ ".stubs.c" );
2261 dependencies
.push_back ( stubsDependency
);
2265 MingwModuleHandler::GetMcObjectDependencies (
2266 vector
<FileLocation
>& dependencies
,
2267 const FileLocation
*file
) const
2269 string basename
= GetBasename ( file
->name
);
2271 FileLocation
defDependency ( IntermediateDirectory
,
2274 dependencies
.push_back ( defDependency
);
2276 FileLocation
stubsDependency ( IntermediateDirectory
,
2277 file
->relative_path
,
2279 dependencies
.push_back ( stubsDependency
);
2283 MingwModuleHandler::GetWidlObjectDependencies (
2284 vector
<FileLocation
>& dependencies
,
2285 const FileLocation
*file
) const
2287 string basename
= GetBasename ( file
->name
);
2288 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2290 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2291 file
->relative_path
,
2292 basename
+ "_s.c" );
2293 dependencies
.push_back ( serverSourceDependency
);
2294 dependencies
.push_back ( *generatedHeaderFilename
);
2296 delete generatedHeaderFilename
;
2300 MingwModuleHandler::GetDefinitionDependencies (
2301 vector
<FileLocation
>& dependencies
) const
2303 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2304 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2306 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2307 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2308 string extension
= GetExtension ( sourceFile
);
2309 if ( extension
== ".spec" || extension
== ".SPEC" )
2310 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2311 if ( extension
== ".idl" || extension
== ".IDL" )
2313 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2314 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2319 enum DebugSupportType
2326 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2332 case DebugKernelMode
:
2333 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2337 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2344 module
.non_if_data
.libraries
.push_back(pLibrary
);
2347 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2348 : MingwModuleHandler ( module_
)
2353 MingwBuildToolModuleHandler::Process ()
2355 GenerateBuildToolModuleTarget ();
2359 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2361 string
targetMacro ( GetTargetMacro (module
) );
2362 string objectsMacro
= GetObjectsMacro ( module
);
2363 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2364 string libsMacro
= GetLibsMacro ();
2369 if ( module
.cplusplus
)
2370 linker
= "${host_gpp}";
2372 linker
= "${host_gcc}";
2374 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2375 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2376 targetMacro
.c_str (),
2377 objectsMacro
.c_str (),
2378 linkDepsMacro
.c_str (),
2379 backend
->GetFullPath ( *target_file
).c_str () );
2380 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2381 fprintf ( fMakefile
,
2382 "\t%s %s -o $@ %s %s\n\n",
2384 GetLinkerMacro ().c_str (),
2385 objectsMacro
.c_str (),
2386 libsMacro
.c_str () );
2392 MingwKernelModuleHandler::MingwKernelModuleHandler (
2393 const Module
& module_
)
2395 : MingwModuleHandler ( module_
)
2400 MingwKernelModuleHandler::Process ()
2402 GenerateKernelModuleTarget ();
2406 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2408 string
targetMacro ( GetTargetMacro ( module
) );
2409 string workingDirectory
= GetWorkingDirectory ( );
2410 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2412 GenerateImportLibraryTargetIfNeeded ();
2414 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2418 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2420 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2421 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2422 module
.baseaddress
.c_str () );
2424 GenerateLinkerCommand ( dependencies
,
2425 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2430 GeneratePhonyTarget();
2435 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2436 const Module
& module_
)
2438 : MingwModuleHandler ( module_
)
2444 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2446 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2450 MingwKernelModeDLLModuleHandler::Process ()
2452 GenerateKernelModeDLLModuleTarget ();
2456 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2458 string
targetMacro ( GetTargetMacro ( module
) );
2459 string workingDirectory
= GetWorkingDirectory ( );
2460 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2462 GenerateImportLibraryTargetIfNeeded ();
2464 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2468 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2470 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2471 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2472 module
.baseaddress
.c_str () );
2473 GenerateLinkerCommand ( dependencies
,
2479 GeneratePhonyTarget();
2484 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2485 const Module
& module_
)
2487 : MingwModuleHandler ( module_
)
2492 MingwKernelModeDriverModuleHandler::AddImplicitLibraries ( Module
& module
)
2494 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2498 MingwKernelModeDriverModuleHandler::Process ()
2500 GenerateKernelModeDriverModuleTarget ();
2505 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2507 string
targetMacro ( GetTargetMacro (module
) );
2508 string workingDirectory
= GetWorkingDirectory ();
2509 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2511 GenerateImportLibraryTargetIfNeeded ();
2513 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2517 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2519 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2520 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2521 module
.baseaddress
.c_str () );
2522 GenerateLinkerCommand ( dependencies
,
2528 GeneratePhonyTarget();
2533 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2534 const Module
& module_
)
2536 : MingwModuleHandler ( module_
)
2541 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2543 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2547 MingwNativeDLLModuleHandler::Process ()
2549 GenerateNativeDLLModuleTarget ();
2553 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2555 string
targetMacro ( GetTargetMacro (module
) );
2556 string workingDirectory
= GetWorkingDirectory ( );
2557 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2559 GenerateImportLibraryTargetIfNeeded ();
2561 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2565 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2567 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2568 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2569 module
.baseaddress
.c_str () );
2570 GenerateLinkerCommand ( dependencies
,
2576 GeneratePhonyTarget();
2581 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2582 const Module
& module_
)
2584 : MingwModuleHandler ( module_
)
2589 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2591 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2595 MingwNativeCUIModuleHandler::Process ()
2597 GenerateNativeCUIModuleTarget ();
2601 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2603 string
targetMacro ( GetTargetMacro (module
) );
2604 string workingDirectory
= GetWorkingDirectory ( );
2605 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2607 GenerateImportLibraryTargetIfNeeded ();
2609 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2613 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2615 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2616 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2617 module
.baseaddress
.c_str () );
2618 GenerateLinkerCommand ( dependencies
,
2624 GeneratePhonyTarget();
2629 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2630 const Module
& module_
)
2632 : MingwModuleHandler ( module_
)
2636 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2637 const Module
& module_
)
2639 : MingwModuleHandler ( module_
)
2644 LinksToCrt( Module
&module
)
2646 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
2648 Library
& library
= *module
.non_if_data
.libraries
[i
];
2649 if ( library
.name
== "libcntpr" || library
.name
== "crt" )
2656 MingwAddImplicitLibraries( Module
&module
)
2661 if ( module
.type
!= Win32DLL
2662 && module
.type
!= Win32OCX
2663 && module
.type
!= Win32CUI
2664 && module
.type
!= Win32GUI
2665 && module
.type
!= Win32SCR
)
2667 // no implicit libraries
2671 links_to_crt
= LinksToCrt ( module
);
2673 if ( !module
.isDefaultEntryPoint
)
2675 if ( module
.GetEntryPoint(false) == "0" )
2677 if ( !links_to_crt
)
2679 pLibrary
= new Library ( module
, "mingw_common" );
2680 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() , pLibrary
);
2682 pLibrary
= new Library ( module
, "msvcrt" );
2683 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2684 links_to_crt
= true;
2690 if ( module
.IsDLL () )
2692 //pLibrary = new Library ( module, "__mingw_dllmain" );
2693 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2697 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2698 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2701 pLibrary
= new Library ( module
, "mingw_common" );
2702 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() + 1, pLibrary
);
2704 if ( !links_to_crt
)
2706 // always link in msvcrt to get the basic routines
2707 pLibrary
= new Library ( module
, "msvcrt" );
2708 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2713 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2715 MingwAddImplicitLibraries ( module
);
2716 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2720 MingwWin32DLLModuleHandler::Process ()
2722 GenerateWin32DLLModuleTarget ();
2726 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2728 string
targetMacro ( GetTargetMacro (module
) );
2729 string workingDirectory
= GetWorkingDirectory ( );
2730 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2732 GenerateImportLibraryTargetIfNeeded ();
2734 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2738 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2740 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2741 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2742 module
.baseaddress
.c_str () );
2743 GenerateLinkerCommand ( dependencies
,
2749 GeneratePhonyTarget();
2755 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2757 MingwAddImplicitLibraries ( module
);
2758 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2762 MingwWin32OCXModuleHandler::Process ()
2764 GenerateWin32OCXModuleTarget ();
2768 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2770 string
targetMacro ( GetTargetMacro (module
) );
2771 string workingDirectory
= GetWorkingDirectory ( );
2772 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2774 GenerateImportLibraryTargetIfNeeded ();
2776 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2780 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2782 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2783 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2784 module
.baseaddress
.c_str () );
2785 GenerateLinkerCommand ( dependencies
,
2791 GeneratePhonyTarget();
2796 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2797 const Module
& module_
)
2799 : MingwModuleHandler ( module_
)
2804 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2806 MingwAddImplicitLibraries ( module
);
2807 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2811 MingwWin32CUIModuleHandler::Process ()
2813 GenerateWin32CUIModuleTarget ();
2817 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2819 string
targetMacro ( GetTargetMacro (module
) );
2820 string workingDirectory
= GetWorkingDirectory ( );
2821 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2823 GenerateImportLibraryTargetIfNeeded ();
2825 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2829 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2831 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2832 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2833 module
.baseaddress
.c_str () );
2834 GenerateLinkerCommand ( dependencies
,
2840 GeneratePhonyTarget();
2845 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2846 const Module
& module_
)
2848 : MingwModuleHandler ( module_
)
2853 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2855 MingwAddImplicitLibraries ( module
);
2856 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2860 MingwWin32GUIModuleHandler::Process ()
2862 GenerateWin32GUIModuleTarget ();
2866 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2868 string
targetMacro ( GetTargetMacro (module
) );
2869 string workingDirectory
= GetWorkingDirectory ( );
2870 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2872 GenerateImportLibraryTargetIfNeeded ();
2874 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2878 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2880 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2881 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2882 module
.baseaddress
.c_str () );
2883 GenerateLinkerCommand ( dependencies
,
2889 GeneratePhonyTarget();
2894 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2895 const Module
& module_
)
2897 : MingwModuleHandler ( module_
)
2902 MingwBootLoaderModuleHandler::Process ()
2904 GenerateBootLoaderModuleTarget ();
2908 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2910 string
targetName ( module
.output
->name
);
2911 string
targetMacro ( GetTargetMacro (module
) );
2912 string workingDirectory
= GetWorkingDirectory ();
2913 FileLocation
junk_tmp ( TemporaryDirectory
,
2915 module
.name
+ ".junk.tmp" );
2916 CLEAN_FILE ( junk_tmp
);
2917 string objectsMacro
= GetObjectsMacro ( module
);
2918 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2919 string libsMacro
= GetLibsMacro ();
2923 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2924 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2925 targetMacro
.c_str (),
2926 objectsMacro
.c_str (),
2927 linkDepsMacro
.c_str (),
2928 backend
->GetFullPath ( *target_file
).c_str () );
2930 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2932 if (Environment::GetArch() == "arm")
2934 fprintf ( fMakefile
,
2935 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
2936 backend
->GetFullName ( junk_tmp
).c_str (),
2937 objectsMacro
.c_str (),
2938 linkDepsMacro
.c_str (),
2939 GetLinkerMacro ().c_str ());
2943 fprintf ( fMakefile
,
2944 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
2945 backend
->GetFullName ( junk_tmp
).c_str (),
2946 objectsMacro
.c_str (),
2947 linkDepsMacro
.c_str (),
2948 GetLinkerMacro ().c_str ());
2950 fprintf ( fMakefile
,
2951 "\t${objcopy} -O binary %s $@\n",
2952 backend
->GetFullName ( junk_tmp
).c_str () );
2953 GenerateBuildMapCode ( &junk_tmp
);
2954 fprintf ( fMakefile
,
2955 "\t-@${rm} %s 2>$(NUL)\n",
2956 backend
->GetFullName ( junk_tmp
).c_str () );
2962 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2963 const Module
& module_
)
2965 : MingwModuleHandler ( module_
)
2970 MingwBootSectorModuleHandler::Process ()
2972 GenerateBootSectorModuleTarget ();
2976 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2978 string objectsMacro
= GetObjectsMacro ( module
);
2982 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2983 module
.name
.c_str ());
2984 fprintf ( fMakefile
,
2986 module
.name
.c_str (),
2987 objectsMacro
.c_str () );
2991 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2992 const Module
& module_
)
2993 : MingwModuleHandler ( module_
)
2998 MingwBootProgramModuleHandler::Process ()
3000 GenerateBootProgramModuleTarget ();
3004 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3006 string
targetName ( module
.output
->name
);
3007 string
targetMacro ( GetTargetMacro (module
) );
3008 string workingDirectory
= GetWorkingDirectory ();
3009 FileLocation
junk_tmp ( TemporaryDirectory
,
3011 module
.name
+ ".junk.tmp" );
3012 FileLocation
junk_elf ( TemporaryDirectory
,
3014 module
.name
+ ".junk.elf" );
3015 FileLocation
junk_cpy ( TemporaryDirectory
,
3017 module
.name
+ ".junk.elf" );
3018 CLEAN_FILE ( junk_tmp
);
3019 CLEAN_FILE ( junk_elf
);
3020 CLEAN_FILE ( junk_cpy
);
3021 string objectsMacro
= GetObjectsMacro ( module
);
3022 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3023 string libsMacro
= GetLibsMacro ();
3024 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3028 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3029 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3030 targetMacro
.c_str (),
3031 objectsMacro
.c_str (),
3032 linkDepsMacro
.c_str (),
3033 payload
->name
.c_str (),
3034 backend
->GetFullPath ( *target_file
).c_str () );
3036 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3038 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3039 module
.buildtype
.c_str (),
3040 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3041 backend
->GetFullName ( junk_cpy
).c_str () );
3043 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3044 module
.buildtype
.c_str (),
3045 backend
->GetFullName ( junk_cpy
).c_str (),
3046 backend
->GetFullName ( junk_tmp
).c_str () );
3048 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3049 module
.buildtype
.c_str (),
3050 linkDepsMacro
.c_str (),
3051 backend
->GetFullName ( junk_tmp
).c_str (),
3052 backend
->GetFullName ( junk_elf
).c_str () );
3054 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3055 module
.buildtype
.c_str (),
3056 backend
->GetFullName ( junk_elf
).c_str (),
3057 backend
->GetFullName ( *module
.output
) .c_str () );
3059 fprintf ( fMakefile
,
3060 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3061 backend
->GetFullName ( junk_tmp
).c_str (),
3062 backend
->GetFullName ( junk_elf
).c_str (),
3063 backend
->GetFullName ( junk_cpy
).c_str () );
3069 MingwIsoModuleHandler::MingwIsoModuleHandler (
3070 const Module
& module_
)
3072 : MingwModuleHandler ( module_
)
3077 MingwIsoModuleHandler::Process ()
3079 GenerateIsoModuleTarget ();
3083 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3084 const string
& bootcdDirectory
)
3086 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3088 const Module
& m
= *module
.project
.modules
[i
];
3091 if ( m
.bootstrap
!= NULL
)
3093 FileLocation
targetFile ( OutputDirectory
,
3094 m
.bootstrap
->base
.length () > 0
3095 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3097 m
.bootstrap
->nameoncd
);
3098 OutputCopyCommand ( *m
.output
, targetFile
);
3104 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3105 const string
& bootcdDirectory
)
3107 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3109 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3110 FileLocation
targetFile ( OutputDirectory
,
3111 cdfile
.target
->relative_path
.length () > 0
3112 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3114 cdfile
.target
->name
);
3115 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3120 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3121 const string
& bootcdDirectory
)
3123 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3125 const Module
& m
= *module
.project
.modules
[i
];
3128 if ( m
.bootstrap
!= NULL
)
3130 FileLocation
targetDirectory ( OutputDirectory
,
3131 m
.bootstrap
->base
.length () > 0
3132 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3135 out
.push_back ( targetDirectory
);
3141 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3142 const string
& bootcdDirectory
)
3144 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3146 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3147 FileLocation
targetDirectory ( OutputDirectory
,
3148 cdfile
.target
->relative_path
.length () > 0
3149 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3152 out
.push_back( targetDirectory
);
3157 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3158 const string
& bootcdDirectory
)
3160 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3161 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3165 MingwIsoModuleHandler::GetBootstrapCdFiles (
3166 vector
<FileLocation
>& out
) const
3168 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3170 const Module
& m
= *module
.project
.modules
[i
];
3173 if ( m
.bootstrap
!= NULL
)
3175 out
.push_back ( *m
.output
);
3181 MingwIsoModuleHandler::GetNonModuleCdFiles (
3182 vector
<FileLocation
>& out
) const
3184 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3186 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3187 out
.push_back ( *cdfile
.source
);
3192 MingwIsoModuleHandler::GetCdFiles (
3193 vector
<FileLocation
>& out
) const
3195 GetBootstrapCdFiles ( out
);
3196 GetNonModuleCdFiles ( out
);
3200 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3202 string bootcdDirectory
= "cd";
3203 FileLocation
bootcd ( OutputDirectory
,
3206 FileLocation
bootcdReactos ( OutputDirectory
,
3207 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3209 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3210 vector
<FileLocation
> vCdDirectories
;
3213 FileLocation
srcunattend ( SourceDirectory
,
3214 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3216 FileLocation
tarunattend ( bootcdReactos
.directory
,
3217 bootcdReactos
.relative_path
,
3219 if (module
.type
== IsoRegTest
)
3220 vSourceFiles
.push_back ( srcunattend
);
3223 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3227 throw InvalidOperationException ( module
.node
.location
.c_str(),
3229 "Invalid bootsector. module '%s' requires <bootsector>",
3230 module
.name
.c_str ());
3233 const FileLocation
*isoboot
= bootModule
->output
;
3234 vSourceFiles
.push_back ( *isoboot
);
3236 // prepare reactos.dff and reactos.inf
3237 FileLocation
reactosDff ( SourceDirectory
,
3238 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3240 FileLocation
reactosInf ( bootcdReactos
.directory
,
3241 bootcdReactos
.relative_path
,
3244 vSourceFiles
.push_back ( reactosDff
);
3247 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3248 Iso/LiveIso outputs are generated in code base root
3250 string IsoName
= module
.output
->name
;
3252 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3255 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3256 GetCdFiles ( vCdFiles
);
3257 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3258 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3260 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3261 module
.name
.c_str ());
3262 fprintf ( fMakefile
,
3263 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3264 module
.name
.c_str (),
3265 backend
->GetFullName ( *isoboot
).c_str (),
3266 sourceFiles
.c_str (),
3268 cdDirectories
.c_str () );
3269 fprintf ( fMakefile
,
3270 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3271 backend
->GetFullName ( reactosDff
).c_str (),
3272 backend
->GetFullPath ( bootcdReactos
).c_str () );
3273 fprintf ( fMakefile
,
3274 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3275 backend
->GetFullName ( reactosDff
).c_str (),
3276 backend
->GetFullName ( reactosInf
).c_str (),
3277 backend
->GetFullPath ( bootcdReactos
).c_str ());
3278 fprintf ( fMakefile
,
3279 "\t-@${rm} %s 2>$(NUL)\n",
3280 backend
->GetFullName ( reactosInf
).c_str () );
3281 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3282 OutputCdfileCopyCommands ( bootcdDirectory
);
3284 if (module
.type
== IsoRegTest
)
3285 OutputCopyCommand ( srcunattend
, tarunattend
);
3287 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3288 fprintf ( fMakefile
,
3289 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3290 backend
->GetFullName ( *isoboot
).c_str (),
3291 backend
->GetFullPath ( bootcd
).c_str (),
3293 fprintf ( fMakefile
,
3298 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3299 const Module
& module_
)
3301 : MingwModuleHandler ( module_
)
3306 MingwLiveIsoModuleHandler::Process ()
3308 GenerateLiveIsoModuleTarget ();
3312 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3314 FileLocation
dir ( OutputDirectory
,
3317 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3321 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3322 string
& reactosDirectory
)
3324 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3326 const Module
& m
= *module
.project
.modules
[i
];
3331 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3332 FileLocation
destination ( OutputDirectory
,
3333 m
.install
->relative_path
.length () > 0
3334 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3335 : livecdDirectory
+ sSep
+ reactosDirectory
,
3337 OutputCopyCommand ( *aliasedModule
.output
,
3344 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3345 string
& reactosDirectory
)
3347 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3349 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3350 FileLocation
target ( OutputDirectory
,
3351 installfile
.target
->relative_path
.length () > 0
3352 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3353 : livecdDirectory
+ sSep
+ reactosDirectory
,
3354 installfile
.target
->name
);
3355 OutputCopyCommand ( *installfile
.source
, target
);
3360 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3362 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3363 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3364 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3365 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3366 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3367 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3369 FileLocation
livecdIni ( SourceDirectory
,
3370 "boot" + sSep
+ "bootdata",
3372 FileLocation
destination ( OutputDirectory
,
3375 OutputCopyCommand ( livecdIni
,
3380 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3382 FileLocation
freeldr ( OutputDirectory
,
3383 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3385 FileLocation
destination ( OutputDirectory
,
3386 livecdDirectory
+ sSep
+ "loader",
3388 OutputCopyCommand ( freeldr
,
3393 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3395 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3396 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3398 fprintf ( fMakefile
,
3399 "\t$(ECHO_MKHIVE)\n" );
3400 fprintf ( fMakefile
,
3401 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3402 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3403 cSep
, cSep
, cSep
, cSep
);
3407 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3409 string livecdDirectory
= module
.name
;
3410 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3415 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3419 throw InvalidOperationException ( module
.node
.location
.c_str(),
3421 "Invalid bootsector. module '%s' requires <bootsector>",
3422 module
.name
.c_str ());
3425 const FileLocation
*isoboot
= bootModule
->output
;
3428 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3429 Iso/LiveIso outputs are generated in code base root
3431 IsoName
= module
.output
->name
;
3433 string reactosDirectory
= "reactos";
3434 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3435 FileLocation
livecdReactos ( OutputDirectory
,
3436 livecdReactosNoFixup
,
3438 CLEAN_FILE ( livecdReactos
);
3440 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3441 module
.name
.c_str ());
3442 fprintf ( fMakefile
,
3443 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3444 module
.name
.c_str (),
3445 backend
->GetFullName ( *isoboot
) .c_str (),
3446 backend
->GetFullPath ( livecdReactos
).c_str () );
3447 OutputModuleCopyCommands ( livecdDirectory
,
3449 OutputNonModuleCopyCommands ( livecdDirectory
,
3451 OutputProfilesDirectoryCommands ( livecdDirectory
);
3452 OutputLoaderCommands ( livecdDirectory
);
3453 OutputRegistryCommands ( livecdDirectory
);
3454 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3455 fprintf ( fMakefile
,
3456 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3457 backend
->GetFullName( *isoboot
).c_str (),
3458 backend
->GetFullPath ( livecd
).c_str (),
3460 fprintf ( fMakefile
,
3465 MingwTestModuleHandler::MingwTestModuleHandler (
3466 const Module
& module_
)
3468 : MingwModuleHandler ( module_
)
3473 MingwTestModuleHandler::Process ()
3475 GenerateTestModuleTarget ();
3478 /* caller needs to delete the returned object */
3480 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3482 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3483 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3484 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3488 MingwTestModuleHandler::GenerateTestModuleTarget ()
3490 string
targetMacro ( GetTargetMacro ( module
) );
3491 string workingDirectory
= GetWorkingDirectory ( );
3492 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3494 GenerateImportLibraryTargetIfNeeded ();
3496 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3500 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3502 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3503 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3504 module
.baseaddress
.c_str () );
3505 GenerateLinkerCommand ( dependencies
,
3511 GeneratePhonyTarget();
3516 MingwAliasModuleHandler::MingwAliasModuleHandler (
3517 const Module
& module_
)
3519 : MingwModuleHandler ( module_
)
3524 MingwAliasModuleHandler::Process ()
3529 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3530 const Module
& module_
)
3532 : MingwModuleHandler ( module_
)
3537 MingwCabinetModuleHandler::Process ()
3539 string
targetMacro ( GetTargetMacro (module
) );
3543 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3544 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3545 targetMacro
.c_str (),
3546 backend
->GetFullPath ( *target_file
).c_str () );
3548 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3549 fprintf ( fMakefile
,
3550 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3551 targetMacro
.c_str (),
3552 module
.name
.c_str());
3555 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3556 const Module
& module_
)
3558 : MingwModuleHandler ( module_
)
3563 MingwElfExecutableModuleHandler::Process ()
3565 string
targetName ( module
.output
->name
);
3566 string
targetMacro ( GetTargetMacro (module
) );
3567 string workingDirectory
= GetWorkingDirectory ();
3568 string objectsMacro
= GetObjectsMacro ( module
);
3569 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3570 string libsMacro
= GetLibsMacro ();
3574 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3575 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3576 targetMacro
.c_str (),
3577 objectsMacro
.c_str (),
3578 linkDepsMacro
.c_str (),
3579 backend
->GetFullPath ( *target_file
).c_str () );
3581 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3583 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3584 module
.buildtype
.c_str(),
3585 objectsMacro
.c_str(),
3587 targetMacro
.c_str () );