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 ) );
35 MingwModuleHandler::backend
= NULL
;
37 MingwModuleHandler::fMakefile
= NULL
;
41 const string
& filename
,
42 const string
& prefix
)
44 if ( !prefix
.length() )
47 const char* pfilename
= filename
.c_str();
48 const char* p1
= strrchr ( pfilename
, '/' );
49 const char* p2
= strrchr ( pfilename
, '\\' );
54 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
57 out
+= prefix
+ pfilename
;
62 GetTargetMacro ( const Module
& module
, bool with_dollar
)
64 string
s ( module
.name
);
68 return ssprintf ( "$(%s)", s
.c_str() );
72 MingwModuleHandler::MingwModuleHandler (
73 const Module
& module_
)
80 MingwModuleHandler::~MingwModuleHandler()
85 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
91 MingwModuleHandler::SetMakefile ( FILE* f
)
97 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
102 /*static*/ const FileLocation
*
103 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
105 switch ( file
->directory
)
107 case SourceDirectory
:
109 case IntermediateDirectory
:
110 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
112 case OutputDirectory
:
113 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
115 case InstallDirectory
:
116 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
119 throw InvalidOperationException ( __FILE__
,
121 "Invalid directory %d.",
128 /* caller needs to delete the returned object */
130 MingwModuleHandler::GetTargetFilename (
131 const Module
& module
,
132 string_list
* pclean_files
)
134 FileLocation
*target
= new FileLocation ( *module
.output
);
137 string_list
& clean_files
= *pclean_files
;
138 CLEAN_FILE ( *target
);
143 /* caller needs to delete the returned object */
145 MingwModuleHandler::GetImportLibraryFilename (
146 const Module
& module
,
147 string_list
* pclean_files
)
149 FileLocation
*target
= new FileLocation ( *module
.dependency
);
152 string_list
& clean_files
= *pclean_files
;
153 CLEAN_FILE ( *target
);
158 /* caller needs to delete the returned object */
160 MingwModuleHandler::InstanciateHandler (
161 const Module
& module
,
162 MingwBackend
* backend
)
164 MingwModuleHandler
* handler
;
165 switch ( module
.type
)
168 handler
= new MingwBuildToolModuleHandler ( module
);
171 handler
= new MingwStaticLibraryModuleHandler ( module
);
174 handler
= new MingwObjectLibraryModuleHandler ( module
);
177 handler
= new MingwKernelModuleHandler ( module
);
180 handler
= new MingwNativeCUIModuleHandler ( module
);
183 handler
= new MingwWin32CUIModuleHandler ( module
);
187 handler
= new MingwWin32GUIModuleHandler ( module
);
190 handler
= new MingwKernelModeDLLModuleHandler ( module
);
193 handler
= new MingwNativeDLLModuleHandler ( module
);
196 handler
= new MingwWin32DLLModuleHandler ( module
);
199 handler
= new MingwWin32OCXModuleHandler ( module
);
201 case KernelModeDriver
:
202 handler
= new MingwKernelModeDriverModuleHandler ( module
);
205 handler
= new MingwBootLoaderModuleHandler ( module
);
208 handler
= new MingwBootSectorModuleHandler ( module
);
211 handler
= new MingwBootProgramModuleHandler ( module
);
214 handler
= new MingwIsoModuleHandler ( module
);
217 handler
= new MingwLiveIsoModuleHandler ( module
);
220 handler
= new MingwIsoModuleHandler ( module
);
223 handler
= new MingwLiveIsoModuleHandler ( module
);
226 handler
= new MingwTestModuleHandler ( module
);
229 handler
= new MingwRpcServerModuleHandler ( module
);
232 handler
= new MingwRpcClientModuleHandler ( module
);
235 handler
= new MingwRpcProxyModuleHandler ( module
);
238 handler
= new MingwAliasModuleHandler ( module
);
241 handler
= new MingwIdlHeaderModuleHandler ( module
);
243 case EmbeddedTypeLib
:
244 handler
= new MingwEmbeddedTypeLibModuleHandler ( module
);
247 handler
= new MingwElfExecutableModuleHandler ( module
);
250 throw UnknownModuleTypeException (
251 module
.node
.location
,
259 MingwModuleHandler::GetWorkingDirectory () const
265 MingwModuleHandler::GetBasename ( const string
& filename
) const
267 size_t index
= filename
.find_last_of ( '.' );
268 if ( index
!= string::npos
)
269 return filename
.substr ( 0, index
);
273 /* caller needs to delete the returned object */
275 MingwModuleHandler::GetActualSourceFilename (
276 const FileLocation
* file
) const
278 string filename
= file
->name
;
280 string extension
= GetExtension ( *file
);
281 if ( extension
== ".spec" || extension
== ".SPEC" )
283 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
, NULL
);
284 FileLocation
*sourceFile
= new FileLocation (
285 objectFile
->directory
,
286 objectFile
->relative_path
,
287 ReplaceExtension ( objectFile
->name
, ".c" ) );
291 else if ( ( extension
== ".idl" || extension
== ".IDL" ) &&
292 ( module
.type
== RpcServer
|| module
.type
== RpcClient
|| module
.type
== RpcProxy
) )
294 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
, NULL
);
295 FileLocation
*sourceFile
= new FileLocation (
296 objectFile
->directory
,
297 objectFile
->relative_path
,
298 ReplaceExtension ( objectFile
->name
, ".c" ) );
302 else if ( extension
== ".mc" || extension
== ".MC" )
304 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
, NULL
);
305 FileLocation
*sourceFile
= new FileLocation (
306 objectFile
->directory
,
307 objectFile
->relative_path
,
308 ReplaceExtension ( objectFile
->name
, ".rc" ) );
313 return new FileLocation ( *file
);
317 MingwModuleHandler::GetExtraDependencies (
318 const FileLocation
*file
) const
320 string extension
= GetExtension ( *file
);
321 if ( extension
== ".idl" || extension
== ".IDL" )
323 const FileLocation
*header
;
324 switch ( module
.type
)
326 case RpcServer
: header
= GetRpcServerHeaderFilename ( file
); break;
327 case RpcClient
: header
= GetRpcClientHeaderFilename ( file
); break;
328 case RpcProxy
: header
= GetRpcProxyHeaderFilename ( file
); break;
329 case IdlHeader
: header
= GetIdlHeaderFilename ( file
); break;
330 default: header
= NULL
; break;
335 string dependencies
= backend
->GetFullName ( *header
);
344 MingwModuleHandler::GetCompilationUnitDependencies (
345 const CompilationUnit
& compilationUnit
) const
347 if ( compilationUnit
.GetFiles ().size () <= 1 )
349 vector
<string
> sourceFiles
;
350 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
352 const File
& file
= *compilationUnit
.GetFiles ()[i
];
353 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
355 return v2s ( sourceFiles
, 10 );
358 /* caller needs to delete the returned object */
360 MingwModuleHandler::GetModuleArchiveFilename () const
362 if ( module
.type
== StaticLibrary
)
363 return GetTargetFilename ( module
, NULL
);
364 return new FileLocation ( IntermediateDirectory
,
365 module
.output
->relative_path
,
366 ReplaceExtension ( module
.name
, ".temp.a" ) );
370 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
372 string extension
= GetExtension ( file
.file
);
373 return ( extension
== ".spec" || extension
== ".SPEC" );
377 MingwModuleHandler::ReferenceObjects (
378 const Module
& module
)
380 if ( module
.type
== ObjectLibrary
)
382 if ( module
.type
== RpcServer
)
384 if ( module
.type
== RpcClient
)
386 if ( module
.type
== RpcProxy
)
388 if ( module
.type
== IdlHeader
)
394 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
395 const FileLocation
& destination
)
400 "\t${cp} %s %s 1>$(NUL)\n",
401 backend
->GetFullName ( source
).c_str (),
402 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
406 MingwModuleHandler::GetImportLibraryDependency (
407 const Module
& importedModule
)
410 if ( ReferenceObjects ( importedModule
) )
412 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
415 dep
= GetTargetMacro ( importedModule
);
416 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
418 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
419 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
420 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
, NULL
);
421 if ( GetExtension ( *objectFilename
) == ".h" )
422 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
423 else if ( GetExtension ( *objectFilename
) == ".rc" )
424 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
429 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
430 dep
= backend
->GetFullName ( *library_target
);
431 delete library_target
;
437 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
438 string_list
& targets
)
440 if ( dependencyModule
.invocations
.size () > 0 )
442 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
444 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
445 invoke
.GetTargets ( targets
);
449 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
453 MingwModuleHandler::GetModuleDependencies (
454 string_list
& dependencies
)
456 size_t iend
= module
.dependencies
.size ();
461 for ( size_t i
= 0; i
< iend
; i
++ )
463 const Dependency
& dependency
= *module
.dependencies
[i
];
464 const Module
& dependencyModule
= *dependency
.dependencyModule
;
465 GetTargets ( dependencyModule
,
468 vector
<FileLocation
> v
;
469 GetDefinitionDependencies ( v
);
471 for ( size_t i
= 0; i
< v
.size (); i
++ )
473 const FileLocation
& file
= v
[i
];
474 dependencies
.push_back ( backend
->GetFullName ( file
) );
479 MingwModuleHandler::GetSourceFilenames ( vector
<FileLocation
>& list
,
480 bool includeGeneratedFiles
) const
484 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
485 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
487 if ( includeGeneratedFiles
|| !compilationUnits
[i
]->IsGeneratedFile () )
489 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
490 const FileLocation
* sourceFileLocation
= GetActualSourceFilename ( &compilationName
);
491 list
.push_back ( *sourceFileLocation
);
492 delete sourceFileLocation
;
495 // intentionally make a copy so that we can append more work in
496 // the middle of processing without having to go recursive
497 vector
<If
*> v
= module
.non_if_data
.ifs
;
498 for ( i
= 0; i
< v
.size (); i
++ )
502 // check for sub-ifs to add to list
503 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
504 for ( j
= 0; j
< ifs
.size (); j
++ )
505 v
.push_back ( ifs
[j
] );
506 const vector
<CompilationUnit
*>& compilationUnits
= rIf
.data
.compilationUnits
;
507 for ( j
= 0; j
< compilationUnits
.size (); j
++ )
509 CompilationUnit
& compilationUnit
= *compilationUnits
[j
];
510 if ( includeGeneratedFiles
|| !compilationUnit
.IsGeneratedFile () )
512 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
513 const FileLocation
* sourceFileLocation
= GetActualSourceFilename ( &compilationName
);
514 list
.push_back ( *sourceFileLocation
);
515 delete sourceFileLocation
;
522 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
523 vector
<FileLocation
>& list
) const
525 GetSourceFilenames ( list
, false );
528 /* caller needs to delete the returned object */
530 MingwModuleHandler::GetObjectFilename (
531 const FileLocation
* sourceFile
,
532 const Module
& module
,
533 string_list
* pclean_files
) const
535 DirectoryLocation destination_directory
;
537 string extension
= GetExtension ( *sourceFile
);
539 if ( module
.type
== BootSector
)
540 return new FileLocation ( *module
.output
);
541 else if ( extension
== ".rc" || extension
== ".RC" )
542 newExtension
= "_" + module
.name
+ ".coff";
543 else if ( extension
== ".mc" || extension
== ".MC" )
544 newExtension
= ".rc";
545 else if ( extension
== ".spec" || extension
== ".SPEC" )
546 newExtension
= ".stubs.o";
547 else if ( extension
== ".idl" || extension
== ".IDL" )
549 if ( module
.type
== RpcServer
)
550 newExtension
= "_s.o";
551 else if ( module
.type
== RpcClient
)
552 newExtension
= "_c.o";
553 else if ( module
.type
== RpcProxy
)
554 newExtension
= "_p.o";
559 newExtension
= "_" + module
.name
+ ".o";
561 if ( module
.type
== BootSector
)
562 destination_directory
= OutputDirectory
;
564 destination_directory
= IntermediateDirectory
;
566 const FileLocation
*obj_file
= new FileLocation(
567 destination_directory
,
568 sourceFile
->relative_path
,
569 ReplaceExtension ( sourceFile
->name
, newExtension
) );
573 string_list
& clean_files
= *pclean_files
;
574 CLEAN_FILE ( *obj_file
);
580 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
582 return module
.name
+ "_clean";
586 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
588 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
590 Library
& library
= *module
.non_if_data
.libraries
[i
];
591 if ( library
.importedModule
->type
== ObjectLibrary
)
592 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
597 MingwModuleHandler::GenerateCleanTarget () const
599 if ( module
.type
== Alias
)
603 ".PHONY: %s_clean\n",
604 module
.name
.c_str() );
605 vector
<string
> referencedModuleNames
;
606 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
609 GetModuleCleanTarget ( module
).c_str(),
610 v2s ( referencedModuleNames
, 10 ).c_str () );
611 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
613 if ( ( i
+ 1 ) % 10 == 9 )
614 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
615 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
617 fprintf ( fMakefile
, " 2>$(NUL)\n" );
619 if( ProxyMakefile::GenerateProxyMakefile(module
) )
621 DirectoryLocation root
;
623 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
624 root
= SourceDirectory
;
626 root
= OutputDirectory
;
628 FileLocation
proxyMakefile ( root
,
629 module
.output
->relative_path
,
631 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
632 backend
->GetFullName ( proxyMakefile
).c_str () );
635 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
639 MingwModuleHandler::GenerateInstallTarget () const
641 if ( !module
.install
)
643 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
646 module
.name
.c_str (),
647 backend
->GetFullName ( *module
.install
).c_str () );
651 MingwModuleHandler::GenerateDependsTarget () const
654 ".PHONY: %s_depends\n",
655 module
.name
.c_str() );
657 "%s_depends: $(RBUILD_TARGET)\n",
658 module
.name
.c_str () );
660 "\t$(ECHO_RBUILD)\n" );
662 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
663 module
.name
.c_str () );
667 MingwModuleHandler::GetObjectFilenames ()
669 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
670 if ( compilationUnits
.size () == 0 )
673 string
objectFilenames ( "" );
674 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
676 if ( objectFilenames
.size () > 0 )
677 objectFilenames
+= " ";
678 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
679 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
, NULL
);
680 objectFilenames
+= backend
->GetFullName ( *object_file
);
683 return objectFilenames
;
687 MingwModuleHandler::GenerateGccDefineParametersFromVector (
688 const vector
<Define
*>& defines
,
689 set
<string
>& used_defs
)
693 for ( size_t i
= 0; i
< defines
.size (); i
++ )
695 Define
& define
= *defines
[i
];
696 if (used_defs
.find(define
.name
) != used_defs
.end())
698 if (parameters
.length () > 0)
700 if (define
.name
.find('(') != string::npos
)
701 parameters
+= "$(QT)";
703 parameters
+= define
.name
;
704 if (define
.value
.length () > 0)
707 parameters
+= define
.value
;
709 if (define
.name
.find('(') != string::npos
)
710 parameters
+= "$(QT)";
711 used_defs
.insert(used_defs
.begin(),define
.name
);
717 MingwModuleHandler::GenerateGccDefineParameters () const
719 set
<string
> used_defs
;
720 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
, used_defs
);
721 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
, used_defs
);
722 if ( s
.length () > 0 )
731 MingwModuleHandler::ConcatenatePaths (
733 const string
& path2
) const
735 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
737 if ( path1
[path1
.length ()] == cSep
)
738 return path1
+ path2
;
740 return path1
+ cSep
+ path2
;
744 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
746 string parameters
, path_prefix
;
747 for ( size_t i
= 0; i
< includes
.size (); i
++ )
749 Include
& include
= *includes
[i
];
750 if ( parameters
.length () > 0 )
752 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
758 MingwModuleHandler::GenerateGccIncludeParameters () const
760 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
761 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
762 if ( s
.length () > 0 )
771 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
774 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
776 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
777 if ( compilerFlag
.compiler
== type
)
779 if ( parameters
.length () > 0 )
781 parameters
+= compilerFlag
.flag
;
788 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
791 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
793 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
794 if ( parameters
.length () > 0 )
796 parameters
+= linkerFlag
.flag
;
802 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
803 const vector
<Library
*>& libraries
)
805 string
dependencies ( "" );
807 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
809 if ( wrap_count
++ == 5 )
810 dependencies
+= " \\\n\t\t", wrap_count
= 0;
811 else if ( dependencies
.size () > 0 )
813 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
819 MingwModuleHandler::GenerateLinkerParameters () const
821 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
825 MingwModuleHandler::GenerateMacro (
826 const char* assignmentOperation
,
828 const IfableData
& data
,
829 set
<const Define
*> *used_defs
,
830 bool generatingCompilerMacro
)
833 bool generateAssignment
;
835 if ( generatingCompilerMacro
)
836 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0 || data
.compilerFlags
.size () > 0;
838 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
839 if ( generateAssignment
)
844 assignmentOperation
);
847 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
852 backend
->GetFullPath ( *pchFilename
).c_str () );
856 if ( generatingCompilerMacro
)
858 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
859 if ( compilerParameters
.size () > 0 )
864 compilerParameters
.c_str () );
867 for ( i
= 0; i
< data
.includes
.size(); i
++ )
869 const Include
& include
= *data
.includes
[i
];
870 const FileLocation
* includeDirectory
= include
.directory
;
874 backend
->GetFullPath ( *includeDirectory
).c_str() );
876 for ( i
= 0; i
< data
.defines
.size(); i
++ )
878 const Define
& define
= *data
.defines
[i
];
881 set
<const Define
*>::const_iterator last_define
;
882 for (last_define
= used_defs
->begin ();
883 last_define
!= used_defs
->end ();
886 if ( (*last_define
)->name
!= define
.name
)
888 if ( !define
.overridable
)
890 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
892 "Invalid override of define '%s', already defined at %s",
893 define
.name
.c_str (),
894 define
.node
->location
.c_str () );
896 if ( backend
->configuration
.Verbose
)
897 printf("%s: Overriding '%s' already defined at %s\n",
898 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
899 define
.node
->location
.c_str () );
902 if ( last_define
!= used_defs
->end () )
908 define
.name
.c_str() );
909 if (define
.value
.length () > 0)
913 define
.value
.c_str() );
915 used_defs
->insert( used_defs
->begin (), &define
);
917 if ( generateAssignment
)
919 fprintf ( fMakefile
, "\n" );
924 MingwModuleHandler::GenerateMacros (
925 const char* assignmentOperation
,
926 const IfableData
& data
,
927 const vector
<LinkerFlag
*>* linkerFlags
,
928 set
<const Define
*>& used_defs
)
932 GenerateMacro ( assignmentOperation
,
937 GenerateMacro ( assignmentOperation
,
943 if ( linkerFlags
!= NULL
)
945 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
946 if ( linkerParameters
.size () > 0 )
951 linkerflagsMacro
.c_str (),
953 linkerParameters
.c_str() );
957 if ( data
.libraries
.size () > 0 )
959 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
960 if ( deps
.size () > 0 )
971 const vector
<If
*>& ifs
= data
.ifs
;
972 for ( i
= 0; i
< ifs
.size(); i
++ )
975 if ( rIf
.data
.defines
.size()
976 || rIf
.data
.includes
.size()
977 || rIf
.data
.libraries
.size()
978 || rIf
.data
.compilationUnits
.size()
979 || rIf
.data
.compilerFlags
.size()
980 || rIf
.data
.ifs
.size() )
984 "%s (\"$(%s)\",\"%s\")\n",
985 rIf
.negated
? "ifneq" : "ifeq",
986 rIf
.property
.c_str(),
1001 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
1003 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
1004 delete compilationUnits
[i
];
1008 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
1013 MingwModuleHandler::GenerateSourceMacros (
1014 const char* assignmentOperation
,
1015 const IfableData
& data
)
1019 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1020 vector
<const FileLocation
*> headers
;
1021 if ( compilationUnits
.size () > 0 )
1026 sourcesMacro
.c_str (),
1027 assignmentOperation
);
1028 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
1030 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1031 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1035 ( i
%10 == 9 ? " \\\n\t" : " " ),
1036 backend
->GetFullName ( compilationName
).c_str () );
1038 fprintf ( fMakefile
, "\n" );
1041 const vector
<If
*>& ifs
= data
.ifs
;
1042 for ( i
= 0; i
< ifs
.size(); i
++ )
1045 if ( rIf
.data
.defines
.size()
1046 || rIf
.data
.includes
.size()
1047 || rIf
.data
.libraries
.size()
1048 || rIf
.data
.compilationUnits
.size()
1049 || rIf
.data
.compilerFlags
.size()
1050 || rIf
.data
.ifs
.size() )
1054 "%s (\"$(%s)\",\"%s\")\n",
1055 rIf
.negated
? "ifneq" : "ifeq",
1056 rIf
.property
.c_str(),
1057 rIf
.value
.c_str() );
1058 GenerateSourceMacros (
1067 vector
<CompilationUnit
*> sourceCompilationUnits
;
1068 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1069 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1071 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1075 sourcesMacro
.c_str(),
1076 backend
->GetFullName ( compilationName
).c_str () );
1078 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1082 MingwModuleHandler::GenerateObjectMacros (
1083 const char* assignmentOperation
,
1084 const IfableData
& data
)
1088 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1089 vector
<const FileLocation
*> headers
;
1090 vector
<const FileLocation
*> mcheaders
;
1091 vector
<const FileLocation
*> mcresources
;
1092 if ( compilationUnits
.size () > 0 )
1094 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1096 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1097 if ( compilationUnit
.IsFirstFile () )
1099 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1100 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
, NULL
);
1101 fprintf ( fMakefile
,
1103 objectsMacro
.c_str(),
1104 backend
->GetFullName ( *object_file
).c_str (),
1105 objectsMacro
.c_str() );
1112 objectsMacro
.c_str (),
1113 assignmentOperation
);
1114 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
1116 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1117 if ( !compilationUnit
.IsFirstFile () )
1119 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1120 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
, NULL
);
1121 if ( GetExtension ( *objectFilename
) == ".h" )
1122 headers
.push_back ( objectFilename
);
1123 else if ( GetExtension ( *objectFilename
) == ".rc" )
1125 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
1126 mcheaders
.push_back ( headerFilename
);
1127 mcresources
.push_back ( objectFilename
);
1134 ( i
%10 == 9 ? " \\\n\t" : " " ),
1135 backend
->GetFullName ( *objectFilename
).c_str () );
1136 delete objectFilename
;
1140 fprintf ( fMakefile
, "\n" );
1142 if ( headers
.size () > 0 )
1147 module
.name
.c_str (),
1148 assignmentOperation
);
1149 for ( i
= 0; i
< headers
.size (); i
++ )
1154 ( i
%10 == 9 ? " \\\n\t" : " " ),
1155 backend
->GetFullName ( *headers
[i
] ).c_str () );
1158 fprintf ( fMakefile
, "\n" );
1161 if ( mcheaders
.size () > 0 )
1166 module
.name
.c_str (),
1167 assignmentOperation
);
1168 for ( i
= 0; i
< mcheaders
.size (); i
++ )
1173 ( i
%10 == 9 ? " \\\n\t" : " " ),
1174 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
1175 delete mcheaders
[i
];
1177 fprintf ( fMakefile
, "\n" );
1180 if ( mcresources
.size () > 0 )
1185 module
.name
.c_str (),
1186 assignmentOperation
);
1187 for ( i
= 0; i
< mcresources
.size (); i
++ )
1192 ( i
%10 == 9 ? " \\\n\t" : " " ),
1193 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
1194 delete mcresources
[i
];
1196 fprintf ( fMakefile
, "\n" );
1199 const vector
<If
*>& ifs
= data
.ifs
;
1200 for ( i
= 0; i
< ifs
.size(); i
++ )
1203 if ( rIf
.data
.defines
.size()
1204 || rIf
.data
.includes
.size()
1205 || rIf
.data
.libraries
.size()
1206 || rIf
.data
.compilationUnits
.size()
1207 || rIf
.data
.compilerFlags
.size()
1208 || rIf
.data
.ifs
.size() )
1212 "%s (\"$(%s)\",\"%s\")\n",
1213 rIf
.negated
? "ifneq" : "ifeq",
1214 rIf
.property
.c_str(),
1215 rIf
.value
.c_str() );
1216 GenerateObjectMacros (
1225 vector
<CompilationUnit
*> sourceCompilationUnits
;
1226 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1227 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1229 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1230 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
, NULL
);
1234 objectsMacro
.c_str(),
1235 backend
->GetFullName ( *object_file
).c_str () );
1238 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1241 /* caller needs to delete the returned object */
1243 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1245 if ( !module
.pch
|| !use_pch
)
1247 return new FileLocation ( IntermediateDirectory
,
1248 module
.pch
->file
.relative_path
,
1249 ReplaceExtension ( module
.pch
->file
.name
, "_" + module
.name
+ ".gch" ) );
1252 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1253 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1254 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1255 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1256 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1258 Rule
gasRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) $(module_rbuild) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1260 "\t${gcc} -x assembler-with-cpp -c $< -o $@ -D__ASM__ $($(module_name)_CFLAGS)\n",
1261 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1262 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1263 Rule
bootRule ( "$(module_output): $(source) $(module_rbuild) | $(OUTPUT)$(SEP)$(source_dir)\n"
1265 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1266 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1267 Rule
nasmRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) $(module_rbuild) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1269 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1270 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1271 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1272 Rule
windresRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source) $(module_rbuild) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1274 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1275 "\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"
1276 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1277 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1278 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1279 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1280 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1281 Rule
wmcRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(WMC_TARGET) $(source)\n"
1283 "\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",
1284 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc", "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h", NULL
);
1285 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source) $(module_rbuild) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1286 "\t$(ECHO_WINEBLD)\n"
1287 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source_path)$(SEP)$(source_name_noext).spec\n"
1288 "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1289 "\t$(ECHO_WINEBLD)\n"
1290 "\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",
1291 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1292 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1293 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1294 Rule
widlHeaderRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1296 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1297 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1298 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1299 Rule
widlServerRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1301 "\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",
1302 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1303 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1304 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1305 Rule
widlClientRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1307 "\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",
1308 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1309 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1310 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1311 Rule
widlProxyRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1313 "\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",
1314 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1315 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1316 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1317 Rule
widlTlbRule ( "$(OUTPUT)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1319 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1320 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1323 MingwModuleHandler::GenerateGccCommand (
1324 const FileLocation
* sourceFile
,
1325 const string
& extraDependencies
)
1327 const FileLocation
*generatedSourceFileName
= GetActualSourceFilename ( sourceFile
);
1328 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1329 string dependencies
= backend
->GetFullName ( *generatedSourceFileName
);
1330 delete generatedSourceFileName
;
1334 string extension
= GetExtension ( *sourceFile
);
1335 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1337 cc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1338 type
= CompilerTypeCPP
;
1342 cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1343 type
= CompilerTypeCC
;
1345 string flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, type
);
1347 flags
= cflagsMacro
+ " " + flags
;
1349 flags
= cflagsMacro
;
1351 if ( extraDependencies
!= "" )
1352 dependencies
+= " " + extraDependencies
;
1355 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1359 /* WIDL generated headers may be used */
1360 vector
<FileLocation
> rpcDependencies
;
1361 GetRpcHeaderDependencies ( rpcDependencies
);
1362 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1363 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1365 const FileLocation
*objectFilename
= GetObjectFilename (
1366 sourceFile
, module
, NULL
);
1367 fprintf ( fMakefile
,
1369 backend
->GetFullName ( *objectFilename
).c_str (),
1370 dependencies
.c_str (),
1371 backend
->GetFullPath ( *objectFilename
).c_str () );
1372 CLEAN_FILE(*objectFilename
);
1373 delete objectFilename
;
1375 fprintf ( fMakefile
, "\t$(ECHO_CC)\n" );
1376 fprintf ( fMakefile
,
1377 "\t%s -c $< -o $@ %s\n",
1383 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1385 for ( size_t i
= 0; i
< module
.project
.non_if_data
.properties
.size (); i
++ )
1387 const Property
& property
= *module
.project
.non_if_data
.properties
[i
];
1388 if ( property
.name
== name
)
1389 return property
.value
;
1391 return string ( "" );
1394 /* caller needs to delete the returned object */
1396 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1398 string newname
= GetBasename ( base
->name
) + "_s.h";
1399 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1402 /* caller needs to delete the returned object */
1404 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1406 string newname
= GetBasename ( base
->name
) + "_c.h";
1407 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1410 /* caller needs to delete the returned object */
1412 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1414 string newname
= GetBasename ( base
->name
) + "_p.h";
1415 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1418 /* caller needs to delete the returned object */
1420 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1422 string newname
= GetBasename ( base
->name
) + ".h";
1423 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1426 /* caller needs to delete the returned object */
1428 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1430 string newname
= GetBasename ( base
->name
) + ".h";
1431 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1435 MingwModuleHandler::GenerateCommands (
1436 const CompilationUnit
& compilationUnit
,
1437 const string
& extraDependencies
)
1439 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1440 string extension
= GetExtension ( sourceFile
);
1441 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1450 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1451 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1452 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1453 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1454 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1455 { HostDontCare
, TypeDontCare
, ".spec", &winebuildRule
},
1456 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1457 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1458 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1459 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1460 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1463 Rule
*customRule
= NULL
;
1465 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1467 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= module
.host
)
1469 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1471 if ( rules
[i
].extension
!= extension
)
1473 customRule
= rules
[i
].rule
;
1478 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1480 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1482 GenerateGccCommand ( &sourceFile
,
1483 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1485 else if ( extension
== ".spec" )
1487 GenerateGccCommand ( &sourceFile
,
1488 extraDependencies
);
1490 else if ( extension
== ".idl" &&
1491 ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
1493 GenerateGccCommand ( &sourceFile
,
1494 GetExtraDependencies ( &sourceFile
) );
1496 else if ( !customRule
)
1498 throw InvalidOperationException ( __FILE__
,
1500 "Unsupported filename extension '%s' in file '%s'",
1502 backend
->GetFullName ( sourceFile
).c_str () );
1507 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1509 fprintf ( fMakefile
,
1510 "ifeq ($(ROS_BUILDMAP),full)\n" );
1512 FileLocation
mapFilename ( OutputDirectory
,
1513 module
.output
->relative_path
,
1514 GetBasename ( module
.output
->name
) + ".map" );
1515 CLEAN_FILE ( mapFilename
);
1517 fprintf ( fMakefile
,
1518 "\t$(ECHO_OBJDUMP)\n" );
1519 fprintf ( fMakefile
,
1520 "\t$(Q)${objdump} -d -S %s > %s\n",
1521 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1522 backend
->GetFullName ( mapFilename
).c_str () );
1524 fprintf ( fMakefile
,
1526 fprintf ( fMakefile
,
1527 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1529 fprintf ( fMakefile
,
1531 fprintf ( fMakefile
,
1532 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1533 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1534 backend
->GetFullName ( mapFilename
).c_str () );
1536 fprintf ( fMakefile
,
1539 fprintf ( fMakefile
,
1544 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1546 fprintf ( fMakefile
,
1547 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1549 FileLocation
nostripFilename ( OutputDirectory
,
1550 module
.output
->relative_path
,
1551 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1552 CLEAN_FILE ( nostripFilename
);
1554 OutputCopyCommand ( *module
.output
, nostripFilename
);
1556 fprintf ( fMakefile
,
1561 MergeStringVector ( const Backend
* backend
,
1562 const vector
<FileLocation
>& input
,
1563 vector
<string
>& output
)
1567 int wrap_count
= -1;
1568 for ( size_t i
= 0; i
< input
.size (); i
++ )
1570 if ( wrap_count
++ == wrap_at
)
1572 output
.push_back ( s
);
1576 else if ( s
.size () > 0)
1578 s
+= backend
->GetFullName ( input
[i
] );
1580 if ( s
.length () > 0 )
1581 output
.push_back ( s
);
1585 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1586 vector
<FileLocation
>& objectFiles
) const
1588 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1590 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1591 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1592 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
, NULL
);
1593 objectFiles
.push_back ( *object_file
);
1599 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1601 if ( backend
->configuration
.CleanAsYouGo
)
1603 vector
<FileLocation
> objectFiles
;
1604 GetObjectsVector ( module
.non_if_data
,
1606 vector
<string
> lines
;
1607 MergeStringVector ( backend
,
1610 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1612 fprintf ( fMakefile
,
1613 "\t-@${rm} %s 2>$(NUL)\n",
1614 lines
[i
].c_str () );
1620 MingwModuleHandler::GenerateRunRsymCode () const
1622 fprintf ( fMakefile
,
1623 "\t$(ECHO_RSYM)\n" );
1624 fprintf ( fMakefile
,
1625 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1629 MingwModuleHandler::GenerateRunStripCode () const
1631 fprintf ( fMakefile
,
1632 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1633 fprintf ( fMakefile
,
1634 "\t$(ECHO_STRIP)\n" );
1635 fprintf ( fMakefile
,
1636 "\t${strip} -s -x -X $@\n\n" );
1637 fprintf ( fMakefile
,
1642 MingwModuleHandler::GenerateLinkerCommand (
1643 const string
& dependencies
,
1644 const string
& linker
,
1645 const string
& linkerParameters
,
1646 const string
& objectsMacro
,
1647 const string
& libsMacro
,
1648 const string
& pefixupParameters
)
1650 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1651 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1653 string
target_macro ( GetTargetMacro ( module
) );
1654 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1656 string linkerScriptArgument
;
1657 if ( module
.linkerScript
!= NULL
)
1658 linkerScriptArgument
= ssprintf ( "-Wl,-T,%s", backend
->GetFullName ( module
.linkerScript
->file
).c_str () );
1660 linkerScriptArgument
= "";
1662 fprintf ( fMakefile
,
1663 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1664 target_macro
.c_str (),
1665 backend
->GetFullName ( *definitionFilename
).c_str (),
1666 dependencies
.c_str (),
1667 target_folder
.c_str () );
1668 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1669 string
targetName ( module
.output
->name
);
1671 if ( !module
.IsDLL () )
1673 fprintf ( fMakefile
,
1674 "\t%s %s %s -o %s %s %s %s\n",
1676 linkerParameters
.c_str (),
1677 linkerScriptArgument
.c_str (),
1678 target_macro
.c_str (),
1679 objectsMacro
.c_str (),
1681 GetLinkerMacro ().c_str () );
1683 else if ( module
.HasImportLibrary () )
1685 FileLocation
temp_exp ( TemporaryDirectory
,
1687 module
.name
+ ".temp.exp" );
1688 CLEAN_FILE ( temp_exp
);
1690 fprintf ( fMakefile
,
1691 "\t${dlltool} --dllname %s --def %s --output-exp %s %s %s\n",
1692 targetName
.c_str (),
1693 backend
->GetFullName ( *definitionFilename
).c_str (),
1694 backend
->GetFullName ( temp_exp
).c_str (),
1695 module
.mangledSymbols
? "" : "--kill-at",
1696 module
.underscoreSymbols
? "--add-underscore" : "" );
1698 fprintf ( fMakefile
,
1699 "\t%s %s %s %s -o %s %s %s %s\n",
1701 linkerParameters
.c_str (),
1702 linkerScriptArgument
.c_str (),
1703 backend
->GetFullName ( temp_exp
).c_str (),
1704 target_macro
.c_str (),
1705 objectsMacro
.c_str (),
1707 GetLinkerMacro ().c_str () );
1709 fprintf ( fMakefile
,
1710 "\t$(Q)$(PEFIXUP_TARGET) %s -exports %s\n",
1711 target_macro
.c_str (),
1712 pefixupParameters
.c_str() );
1714 fprintf ( fMakefile
,
1715 "\t-@${rm} %s 2>$(NUL)\n",
1716 backend
->GetFullName ( temp_exp
).c_str () );
1720 /* XXX: need to workaround binutils bug, which exports
1721 * all functions in a dll if no .def file or an empty
1722 * one has been provided... */
1724 //printf ( "%s will have all its functions exported\n",
1725 // module.target->name.c_str () );
1726 fprintf ( fMakefile
,
1727 "\t%s %s %s -o %s %s %s %s\n",
1729 linkerParameters
.c_str (),
1730 linkerScriptArgument
.c_str (),
1731 target_macro
.c_str (),
1732 objectsMacro
.c_str (),
1734 GetLinkerMacro ().c_str () );
1737 GenerateBuildMapCode ();
1738 GenerateBuildNonSymbolStrippedCode ();
1739 GenerateRunRsymCode ();
1740 GenerateRunStripCode ();
1741 GenerateCleanObjectsAsYouGoCode ();
1743 delete definitionFilename
;
1748 MingwModuleHandler::GeneratePhonyTarget() const
1750 string
targetMacro ( GetTargetMacro ( module
) );
1751 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1753 fprintf ( fMakefile
,
1755 targetMacro
.c_str ());
1756 fprintf ( fMakefile
, "%s: | %s\n",
1757 targetMacro
.c_str (),
1758 backend
->GetFullPath ( *target_file
).c_str () );
1764 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1767 string moduleDependencies
;
1769 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1770 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1772 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1773 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1774 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
, NULL
);
1775 if ( GetExtension ( *objectFilename
) == ".h" )
1776 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1777 else if ( GetExtension ( *objectFilename
) == ".rc" )
1778 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1779 delete objectFilename
;
1782 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1784 GenerateCommands ( *compilationUnits
[i
],
1785 moduleDependencies
);
1786 fprintf ( fMakefile
,
1790 const vector
<If
*>& ifs
= data
.ifs
;
1791 for ( i
= 0; i
< ifs
.size(); i
++ )
1793 GenerateObjectFileTargets ( ifs
[i
]->data
);
1796 vector
<CompilationUnit
*> sourceCompilationUnits
;
1797 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1798 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1800 GenerateCommands ( *sourceCompilationUnits
[i
],
1801 moduleDependencies
);
1803 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1807 MingwModuleHandler::GenerateObjectFileTargets ()
1809 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1813 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1814 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1816 const FileLocation
& baseHeaderFile
= module
.pch
->file
;
1817 CLEAN_FILE ( *pchFilename
);
1818 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1819 /* WIDL generated headers may be used */
1820 vector
<FileLocation
> rpcDependencies
;
1821 GetRpcHeaderDependencies ( rpcDependencies
);
1822 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1823 fprintf ( fMakefile
,
1825 backend
->GetFullName ( *pchFilename
).c_str(),
1826 dependencies
.c_str(),
1827 backend
->GetFullPath ( *pchFilename
).c_str() );
1828 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1829 fprintf ( fMakefile
,
1830 "\t%s -o %s %s -g %s\n\n",
1831 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1832 backend
->GetFullName ( *pchFilename
).c_str(),
1833 cflagsMacro
.c_str(),
1834 backend
->GetFullName ( baseHeaderFile
).c_str() );
1838 GenerateObjectFileTargets ( module
.non_if_data
);
1839 fprintf ( fMakefile
, "\n" );
1842 /* caller needs to delete the returned object */
1844 MingwModuleHandler::GenerateArchiveTarget ()
1846 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1848 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1850 if ( module
.type
== StaticLibrary
&& module
.importLibrary
)
1852 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1854 fprintf ( fMakefile
,
1855 "\t${dlltool} --dllname %s --def %s --output-lib $@ %s %s\n",
1856 module
.importLibrary
->dllname
.c_str (),
1857 backend
->GetFullName ( *definitionFilename
).c_str (),
1858 module
.mangledSymbols
? "" : "--kill-at",
1859 module
.underscoreSymbols
? "--add-underscore" : "" );
1861 delete definitionFilename
;
1864 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1866 GenerateCleanObjectsAsYouGoCode ();
1868 fprintf ( fMakefile
, "\n" );
1870 return archiveFilename
;
1874 MingwModuleHandler::GetCFlagsMacro () const
1876 return ssprintf ( "$(%s_CFLAGS)",
1877 module
.name
.c_str () );
1881 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1883 return ssprintf ( "$(%s_OBJS)",
1884 module
.name
.c_str () );
1888 MingwModuleHandler::GetLinkingDependenciesMacro () const
1890 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1894 MingwModuleHandler::GetLibsMacro () const
1896 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1900 MingwModuleHandler::GetLinkerMacro () const
1902 return ssprintf ( "$(%s_LFLAGS)",
1903 module
.name
.c_str () );
1907 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1909 if ( ReferenceObjects ( module
) )
1910 return GetObjectsMacro ( module
);
1913 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1914 string target
= backend
->GetFullName ( *target_file
).c_str ();
1921 MingwModuleHandler::GenerateSourceMacro ()
1923 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1925 GenerateSourceMacros (
1927 module
.non_if_data
);
1929 // future references to the macro will be to get its values
1930 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1934 MingwModuleHandler::GenerateObjectMacro ()
1936 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1938 GenerateObjectMacros (
1940 module
.non_if_data
);
1942 // future references to the macro will be to get its values
1943 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1947 MingwModuleHandler::GenerateTargetMacro ()
1949 fprintf ( fMakefile
,
1951 GetTargetMacro ( module
, false ).c_str (),
1952 GetModuleTargets ( module
).c_str () );
1956 MingwModuleHandler::GetRpcHeaderDependencies (
1957 vector
<FileLocation
>& dependencies
) const
1959 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1961 Library
& library
= *module
.non_if_data
.libraries
[i
];
1962 if ( library
.importedModule
->type
== RpcServer
||
1963 library
.importedModule
->type
== RpcClient
||
1964 library
.importedModule
->type
== RpcProxy
||
1965 library
.importedModule
->type
== IdlHeader
)
1967 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1969 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1970 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1971 string extension
= GetExtension ( sourceFile
);
1972 if ( extension
== ".idl" || extension
== ".IDL" )
1974 string basename
= GetBasename ( sourceFile
.name
);
1975 if ( library
.importedModule
->type
== RpcServer
)
1977 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1978 dependencies
.push_back ( *header
);
1981 if ( library
.importedModule
->type
== RpcClient
)
1983 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1984 dependencies
.push_back ( *header
);
1987 if ( library
.importedModule
->type
== RpcProxy
)
1989 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1990 dependencies
.push_back ( *header
);
1993 if ( library
.importedModule
->type
== IdlHeader
)
1995 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1996 dependencies
.push_back ( *header
);
2006 MingwModuleHandler::GenerateOtherMacros ()
2008 set
<const Define
*> used_defs
;
2010 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
2011 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
2012 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
2013 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
2014 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
2015 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
2016 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
2021 &module
.linkerFlags
,
2026 module
.project
.non_if_data
,
2030 vector
<FileLocation
> s
;
2031 if ( module
.importLibrary
)
2033 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2034 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2036 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2037 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2038 string extension
= GetExtension ( sourceFile
);
2039 if ( extension
== ".spec" || extension
== ".SPEC" )
2040 GetSpecObjectDependencies ( s
, &sourceFile
);
2043 if ( s
.size () > 0 )
2048 linkDepsMacro
.c_str() );
2049 for ( size_t i
= 0; i
< s
.size(); i
++ )
2050 fprintf ( fMakefile
,
2052 backend
->GetFullName ( s
[i
] ).c_str () );
2053 fprintf ( fMakefile
, "\n" );
2056 string globalCflags
= "-g";
2057 if ( backend
->usePipe
)
2058 globalCflags
+= " -pipe";
2059 if ( !module
.allowWarnings
)
2060 globalCflags
+= " -Werror";
2061 if ( module
.host
== HostTrue
)
2063 if ( module
.cplusplus
)
2064 globalCflags
+= " $(HOST_CPPFLAGS)";
2066 globalCflags
+= " $(HOST_CFLAGS)";
2070 if ( module
.cplusplus
)
2072 // HACK: use host headers when building C++
2073 globalCflags
+= " $(HOST_CPPFLAGS)";
2076 globalCflags
+= " -nostdinc";
2079 // Always force disabling of sibling calls optimisation for GCC
2080 // (TODO: Move to version-specific once this bug is fixed in GCC)
2081 globalCflags
+= " -fno-optimize-sibling-calls";
2085 "%s += $(PROJECT_CFLAGS) %s\n",
2086 cflagsMacro
.c_str (),
2087 globalCflags
.c_str () );
2091 "%s += $(PROJECT_RCFLAGS)\n",
2092 windresflagsMacro
.c_str () );
2096 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
2097 widlflagsMacro
.c_str (),
2098 module
.output
->relative_path
.c_str () );
2102 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
2103 module
.name
.c_str () );
2108 linkDepsMacro
.c_str (),
2109 libsMacro
.c_str () );
2111 string cflags
= TypeSpecificCFlags();
2112 if ( cflags
.size() > 0 )
2114 fprintf ( fMakefile
,
2116 cflagsMacro
.c_str (),
2120 string nasmflags
= TypeSpecificNasmFlags();
2121 if ( nasmflags
.size () > 0 )
2123 fprintf ( fMakefile
,
2125 nasmflagsMacro
.c_str (),
2126 nasmflags
.c_str () );
2129 string linkerflags
= TypeSpecificLinkerFlags();
2130 if ( linkerflags
.size() > 0 )
2132 fprintf ( fMakefile
,
2134 linkerflagsMacro
.c_str (),
2135 linkerflags
.c_str () );
2138 if ( module
.type
== StaticLibrary
&& module
.isStartupLib
)
2140 fprintf ( fMakefile
,
2141 "%s += -Wno-main\n\n",
2142 cflagsMacro
.c_str () );
2145 fprintf ( fMakefile
, "\n\n" );
2147 // future references to the macros will be to get their values
2148 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2149 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2150 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2154 MingwModuleHandler::GenerateRules ()
2156 string targetMacro
= GetTargetMacro ( module
);
2157 //CLEAN_FILE ( targetMacro );
2158 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2160 // generate phony target for module name
2161 fprintf ( fMakefile
, ".PHONY: %s\n",
2162 module
.name
.c_str () );
2163 string dependencies
= GetTargetMacro ( module
);
2164 if ( module
.type
== Test
)
2165 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2166 fprintf ( fMakefile
, "%s: %s\n\n",
2167 module
.name
.c_str (),
2168 dependencies
.c_str () );
2169 if ( module
.type
== Test
)
2171 fprintf ( fMakefile
,
2173 targetMacro
.c_str ());
2176 if ( !ReferenceObjects ( module
) )
2178 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2182 GenerateObjectFileTargets ();
2186 MingwModuleHandler::GetInvocationDependencies (
2187 const Module
& module
,
2188 string_list
& dependencies
)
2190 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2192 Invoke
& invoke
= *module
.invocations
[i
];
2193 if ( invoke
.invokeModule
== &module
)
2194 /* Protect against circular dependencies */
2196 invoke
.GetTargets ( dependencies
);
2201 MingwModuleHandler::GenerateInvocations () const
2203 if ( module
.invocations
.size () == 0 )
2206 size_t iend
= module
.invocations
.size ();
2207 for ( size_t i
= 0; i
< iend
; i
++ )
2209 const Invoke
& invoke
= *module
.invocations
[i
];
2211 if ( invoke
.invokeModule
->type
!= BuildTool
)
2213 throw XMLInvalidBuildFileException (
2214 module
.node
.location
,
2215 "Only modules of type buildtool can be invoked." );
2218 string invokeTarget
= module
.GetInvocationTarget ( i
);
2219 string_list invoke_targets
;
2220 assert ( invoke_targets
.size() );
2221 invoke
.GetTargets ( invoke_targets
);
2222 fprintf ( fMakefile
,
2224 invokeTarget
.c_str () );
2225 fprintf ( fMakefile
,
2227 invokeTarget
.c_str () );
2228 size_t j
, jend
= invoke_targets
.size();
2229 for ( j
= 0; j
< jend
; j
++ )
2231 fprintf ( fMakefile
,
2233 invoke_targets
[i
].c_str () );
2235 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2236 for ( j
= 1; j
< jend
; j
++ )
2237 fprintf ( fMakefile
,
2239 invoke_targets
[i
].c_str () );
2240 fprintf ( fMakefile
,
2242 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2243 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2244 fprintf ( fMakefile
,
2246 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2247 invoke
.GetParameters ().c_str () );
2252 MingwModuleHandler::GetPreconditionDependenciesName () const
2254 return module
.name
+ "_precondition";
2258 MingwModuleHandler::GetDefaultDependencies (
2259 string_list
& dependencies
) const
2261 /* Avoid circular dependency */
2262 if ( module
.type
!= BuildTool
2263 && module
.name
!= "zlib"
2264 && module
.name
!= "hostzlib" )
2266 dependencies
.push_back ( "$(INIT)" );
2268 if ( module
.type
!= BuildTool
2269 && module
.name
!= "psdk" )
2271 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2273 /* Check if any dependent library relays on the generated headers */
2274 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2276 const Module
& m
= *module
.project
.modules
[i
];
2277 for ( size_t j
= 0; j
< m
.non_if_data
.compilationUnits
.size (); j
++ )
2279 CompilationUnit
& compilationUnit
= *m
.non_if_data
.compilationUnits
[j
];
2280 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2281 string extension
= GetExtension ( sourceFile
);
2282 if (extension
== ".mc" || extension
== ".MC" )
2284 string dependency
= ssprintf ( " $(%s_MCHEADERS)", m
.name
.c_str () );
2285 dependencies
.push_back ( dependency
);
2292 MingwModuleHandler::GeneratePreconditionDependencies ()
2294 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2295 vector
<FileLocation
> sourceFilenames
;
2296 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
2297 string_list dependencies
;
2298 GetDefaultDependencies ( dependencies
);
2299 GetModuleDependencies ( dependencies
);
2301 GetInvocationDependencies ( module
, dependencies
);
2303 if ( dependencies
.size() )
2305 fprintf ( fMakefile
,
2307 preconditionDependenciesName
.c_str () );
2308 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2309 fprintf ( fMakefile
,
2311 dependencies
[i
].c_str () );
2312 fprintf ( fMakefile
, "\n\n" );
2315 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
2317 fprintf ( fMakefile
,
2319 backend
->GetFullName ( sourceFilenames
[i
] ).c_str (),
2320 preconditionDependenciesName
.c_str ());
2322 fprintf ( fMakefile
, "\n" );
2326 MingwModuleHandler::IsWineModule () const
2328 if ( module
.importLibrary
== NULL
)
2331 size_t index
= module
.importLibrary
->source
->name
.rfind ( ".spec.def" );
2332 return ( index
!= string::npos
);
2335 /* caller needs to delete the returned object */
2337 MingwModuleHandler::GetDefinitionFilename () const
2339 if ( module
.importLibrary
!= NULL
)
2341 DirectoryLocation directory
;
2342 if ( IsWineModule () )
2343 directory
= IntermediateDirectory
;
2345 directory
= SourceDirectory
;
2347 return new FileLocation ( directory
,
2348 module
.importLibrary
->source
->relative_path
,
2349 module
.importLibrary
->source
->name
);
2352 return new FileLocation ( SourceDirectory
, "tools" + sSep
+ "rbuild", "empty.def" );
2356 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2358 if ( module
.importLibrary
!= NULL
)
2360 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2361 const FileLocation
*defFilename
= GetDefinitionFilename ();
2363 vector
<FileLocation
> deps
;
2364 GetDefinitionDependencies ( deps
);
2366 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
2368 fprintf ( fMakefile
, "%s: %s",
2369 backend
->GetFullName ( *library_target
).c_str (),
2370 backend
->GetFullName ( *defFilename
).c_str () );
2372 size_t i
, iend
= deps
.size();
2373 for ( i
= 0; i
< iend
; i
++ )
2374 fprintf ( fMakefile
, " %s",
2375 backend
->GetFullName ( deps
[i
] ).c_str () );
2377 fprintf ( fMakefile
, " | %s\n",
2378 backend
->GetFullPath ( *library_target
).c_str () );
2380 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2382 fprintf ( fMakefile
,
2383 "\t${dlltool} --dllname %s --def %s --output-lib %s %s %s\n\n",
2384 module
.output
->name
.c_str (),
2385 backend
->GetFullName ( *defFilename
).c_str (),
2386 backend
->GetFullName ( *library_target
).c_str (),
2387 module
.mangledSymbols
? "" : "--kill-at",
2388 module
.underscoreSymbols
? "--add-underscore" : "" );
2391 delete library_target
;
2396 MingwModuleHandler::GetSpecObjectDependencies (
2397 vector
<FileLocation
>& dependencies
,
2398 const FileLocation
*file
) const
2400 string basename
= GetBasename ( file
->name
);
2402 FileLocation
defDependency ( IntermediateDirectory
,
2403 file
->relative_path
,
2404 basename
+ ".spec.def" );
2405 dependencies
.push_back ( defDependency
);
2407 FileLocation
stubsDependency ( IntermediateDirectory
,
2408 file
->relative_path
,
2409 basename
+ ".stubs.c" );
2410 dependencies
.push_back ( stubsDependency
);
2414 MingwModuleHandler::GetMcObjectDependencies (
2415 vector
<FileLocation
>& dependencies
,
2416 const FileLocation
*file
) const
2418 string basename
= GetBasename ( file
->name
);
2420 FileLocation
defDependency ( IntermediateDirectory
,
2423 dependencies
.push_back ( defDependency
);
2425 FileLocation
stubsDependency ( IntermediateDirectory
,
2426 file
->relative_path
,
2428 dependencies
.push_back ( stubsDependency
);
2432 MingwModuleHandler::GetWidlObjectDependencies (
2433 vector
<FileLocation
>& dependencies
,
2434 const FileLocation
*file
) const
2436 string basename
= GetBasename ( file
->name
);
2437 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2439 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2440 file
->relative_path
,
2441 basename
+ "_s.c" );
2442 dependencies
.push_back ( serverSourceDependency
);
2443 dependencies
.push_back ( *generatedHeaderFilename
);
2445 delete generatedHeaderFilename
;
2449 MingwModuleHandler::GetDefinitionDependencies (
2450 vector
<FileLocation
>& dependencies
) const
2452 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2453 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2455 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2456 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2457 string extension
= GetExtension ( sourceFile
);
2458 if ( extension
== ".spec" || extension
== ".SPEC" )
2459 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2460 if ( extension
== ".idl" || extension
== ".IDL" )
2462 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2463 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2468 enum DebugSupportType
2475 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2481 case DebugKernelMode
:
2482 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2486 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2493 module
.non_if_data
.libraries
.push_back(pLibrary
);
2496 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2497 : MingwModuleHandler ( module_
)
2502 MingwBuildToolModuleHandler::Process ()
2504 GenerateBuildToolModuleTarget ();
2508 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2510 string
targetMacro ( GetTargetMacro (module
) );
2511 string objectsMacro
= GetObjectsMacro ( module
);
2512 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2513 string libsMacro
= GetLibsMacro ();
2518 if ( module
.cplusplus
)
2519 linker
= "${host_gpp}";
2521 linker
= "${host_gcc}";
2523 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2524 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2525 targetMacro
.c_str (),
2526 objectsMacro
.c_str (),
2527 linkDepsMacro
.c_str (),
2528 backend
->GetFullPath ( *target_file
).c_str () );
2529 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2530 fprintf ( fMakefile
,
2531 "\t%s %s -o $@ %s %s\n\n",
2533 GetLinkerMacro ().c_str (),
2534 objectsMacro
.c_str (),
2535 libsMacro
.c_str () );
2541 MingwKernelModuleHandler::MingwKernelModuleHandler (
2542 const Module
& module_
)
2544 : MingwModuleHandler ( module_
)
2549 MingwKernelModuleHandler::Process ()
2551 GenerateKernelModuleTarget ();
2555 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2557 string
targetMacro ( GetTargetMacro ( module
) );
2558 string workingDirectory
= GetWorkingDirectory ( );
2559 string objectsMacro
= GetObjectsMacro ( module
);
2560 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2561 string libsMacro
= GetLibsMacro ();
2563 GenerateImportLibraryTargetIfNeeded ();
2565 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2569 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2571 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s",
2572 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2573 module
.baseaddress
.c_str () );
2575 GenerateLinkerCommand ( dependencies
,
2577 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2584 GeneratePhonyTarget();
2589 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2590 const Module
& module_
)
2592 : MingwModuleHandler ( module_
)
2597 MingwStaticLibraryModuleHandler::Process ()
2599 GenerateStaticLibraryModuleTarget ();
2603 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2609 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2610 const Module
& module_
)
2612 : MingwModuleHandler ( module_
)
2617 MingwObjectLibraryModuleHandler::Process ()
2619 GenerateObjectLibraryModuleTarget ();
2623 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2629 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2630 const Module
& module_
)
2632 : MingwModuleHandler ( module_
)
2636 MingwEmbeddedTypeLibModuleHandler::MingwEmbeddedTypeLibModuleHandler (
2637 const Module
& module_
)
2639 : MingwModuleHandler ( module_
)
2644 MingwEmbeddedTypeLibModuleHandler::Process ()
2651 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2653 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2657 MingwKernelModeDLLModuleHandler::Process ()
2659 GenerateKernelModeDLLModuleTarget ();
2663 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2665 string
targetMacro ( GetTargetMacro ( module
) );
2666 string workingDirectory
= GetWorkingDirectory ( );
2667 string objectsMacro
= GetObjectsMacro ( module
);
2668 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2669 string libsMacro
= GetLibsMacro ();
2671 GenerateImportLibraryTargetIfNeeded ();
2673 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2677 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2679 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
2680 module
.GetEntryPoint(true).c_str (),
2681 module
.baseaddress
.c_str () );
2682 GenerateLinkerCommand ( dependencies
,
2691 GeneratePhonyTarget();
2696 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2697 const Module
& module_
)
2699 : MingwModuleHandler ( module_
)
2704 MingwKernelModeDriverModuleHandler::AddImplicitLibraries ( Module
& module
)
2706 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2710 MingwKernelModeDriverModuleHandler::Process ()
2712 GenerateKernelModeDriverModuleTarget ();
2717 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2719 string
targetMacro ( GetTargetMacro (module
) );
2720 string workingDirectory
= GetWorkingDirectory ();
2721 string objectsMacro
= GetObjectsMacro ( module
);
2722 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2723 string libsMacro
= GetLibsMacro ();
2725 GenerateImportLibraryTargetIfNeeded ();
2727 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2731 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2733 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
2734 module
.GetEntryPoint(true).c_str (),
2735 module
.baseaddress
.c_str () );
2736 GenerateLinkerCommand ( dependencies
,
2745 GeneratePhonyTarget();
2750 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2751 const Module
& module_
)
2753 : MingwModuleHandler ( module_
)
2758 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2760 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2764 MingwNativeDLLModuleHandler::Process ()
2766 GenerateNativeDLLModuleTarget ();
2770 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2772 string
targetMacro ( GetTargetMacro (module
) );
2773 string workingDirectory
= GetWorkingDirectory ( );
2774 string objectsMacro
= GetObjectsMacro ( module
);
2775 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2776 string libsMacro
= GetLibsMacro ();
2778 GenerateImportLibraryTargetIfNeeded ();
2780 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2784 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2786 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -shared",
2787 module
.GetEntryPoint(true).c_str (),
2788 module
.baseaddress
.c_str () );
2789 GenerateLinkerCommand ( dependencies
,
2798 GeneratePhonyTarget();
2803 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2804 const Module
& module_
)
2806 : MingwModuleHandler ( module_
)
2811 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2813 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2817 MingwNativeCUIModuleHandler::Process ()
2819 GenerateNativeCUIModuleTarget ();
2823 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2825 string
targetMacro ( GetTargetMacro (module
) );
2826 string workingDirectory
= GetWorkingDirectory ( );
2827 string objectsMacro
= GetObjectsMacro ( module
);
2828 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2829 string libsMacro
= GetLibsMacro ();
2831 GenerateImportLibraryTargetIfNeeded ();
2833 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2837 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2839 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2840 module
.GetEntryPoint(true).c_str (),
2841 module
.baseaddress
.c_str () );
2842 GenerateLinkerCommand ( dependencies
,
2851 GeneratePhonyTarget();
2856 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2857 const Module
& module_
)
2859 : MingwModuleHandler ( module_
)
2863 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2864 const Module
& module_
)
2866 : MingwModuleHandler ( module_
)
2871 LinksToCrt( Module
&module
)
2873 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
2875 Library
& library
= *module
.non_if_data
.libraries
[i
];
2876 if ( library
.name
== "libcntpr" || library
.name
== "crt" )
2883 MingwAddImplicitLibraries( Module
&module
)
2888 if ( module
.type
!= Win32DLL
2889 && module
.type
!= Win32OCX
2890 && module
.type
!= Win32CUI
2891 && module
.type
!= Win32GUI
2892 && module
.type
!= Win32SCR
)
2894 // no implicit libraries
2898 links_to_crt
= LinksToCrt ( module
);
2900 if ( !module
.isDefaultEntryPoint
)
2902 if ( module
.GetEntryPoint(false) == "0" )
2904 if ( !links_to_crt
)
2906 pLibrary
= new Library ( module
, "mingw_common" );
2907 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() , pLibrary
);
2909 pLibrary
= new Library ( module
, "msvcrt" );
2910 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2911 links_to_crt
= true;
2917 if ( module
.IsDLL () )
2919 //pLibrary = new Library ( module, "__mingw_dllmain" );
2920 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2924 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2925 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2928 pLibrary
= new Library ( module
, "mingw_common" );
2929 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() + 1, pLibrary
);
2931 if ( !links_to_crt
)
2933 // always link in msvcrt to get the basic routines
2934 pLibrary
= new Library ( module
, "msvcrt" );
2935 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2940 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2942 MingwAddImplicitLibraries ( module
);
2943 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2947 MingwWin32DLLModuleHandler::Process ()
2949 GenerateWin32DLLModuleTarget ();
2953 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2955 string
targetMacro ( GetTargetMacro (module
) );
2956 string workingDirectory
= GetWorkingDirectory ( );
2957 string objectsMacro
= GetObjectsMacro ( module
);
2958 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2959 string libsMacro
= GetLibsMacro ();
2961 GenerateImportLibraryTargetIfNeeded ();
2963 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2967 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2970 if ( module
.cplusplus
)
2975 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
2976 module
.GetEntryPoint(true).c_str (),
2977 module
.baseaddress
.c_str () );
2978 GenerateLinkerCommand ( dependencies
,
2987 GeneratePhonyTarget();
2993 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2995 MingwAddImplicitLibraries ( module
);
2996 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3000 MingwWin32OCXModuleHandler::Process ()
3002 GenerateWin32OCXModuleTarget ();
3006 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
3008 string
targetMacro ( GetTargetMacro (module
) );
3009 string workingDirectory
= GetWorkingDirectory ( );
3010 string objectsMacro
= GetObjectsMacro ( module
);
3011 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3012 string libsMacro
= GetLibsMacro ();
3014 GenerateImportLibraryTargetIfNeeded ();
3016 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3020 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3023 if ( module
.cplusplus
)
3028 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
3029 module
.GetEntryPoint(true).c_str (),
3030 module
.baseaddress
.c_str () );
3031 GenerateLinkerCommand ( dependencies
,
3040 GeneratePhonyTarget();
3045 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
3046 const Module
& module_
)
3048 : MingwModuleHandler ( module_
)
3053 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3055 MingwAddImplicitLibraries ( module
);
3056 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3060 MingwWin32CUIModuleHandler::Process ()
3062 GenerateWin32CUIModuleTarget ();
3066 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
3068 string
targetMacro ( GetTargetMacro (module
) );
3069 string workingDirectory
= GetWorkingDirectory ( );
3070 string objectsMacro
= GetObjectsMacro ( module
);
3071 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3072 string libsMacro
= GetLibsMacro ();
3074 GenerateImportLibraryTargetIfNeeded ();
3076 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3080 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3083 if ( module
.cplusplus
)
3088 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3089 module
.GetEntryPoint(true).c_str (),
3090 module
.baseaddress
.c_str () );
3091 GenerateLinkerCommand ( dependencies
,
3100 GeneratePhonyTarget();
3105 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
3106 const Module
& module_
)
3108 : MingwModuleHandler ( module_
)
3113 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3115 MingwAddImplicitLibraries ( module
);
3116 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3120 MingwWin32GUIModuleHandler::Process ()
3122 GenerateWin32GUIModuleTarget ();
3126 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
3128 string
targetMacro ( GetTargetMacro (module
) );
3129 string workingDirectory
= GetWorkingDirectory ( );
3130 string objectsMacro
= GetObjectsMacro ( module
);
3131 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3132 string libsMacro
= GetLibsMacro ();
3134 GenerateImportLibraryTargetIfNeeded ();
3136 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3140 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3143 if ( module
.cplusplus
)
3148 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3149 module
.GetEntryPoint(true).c_str (),
3150 module
.baseaddress
.c_str () );
3151 GenerateLinkerCommand ( dependencies
,
3160 GeneratePhonyTarget();
3165 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
3166 const Module
& module_
)
3168 : MingwModuleHandler ( module_
)
3173 MingwBootLoaderModuleHandler::Process ()
3175 GenerateBootLoaderModuleTarget ();
3179 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
3181 string
targetName ( module
.output
->name
);
3182 string
targetMacro ( GetTargetMacro (module
) );
3183 string workingDirectory
= GetWorkingDirectory ();
3184 FileLocation
junk_tmp ( TemporaryDirectory
,
3186 module
.name
+ ".junk.tmp" );
3187 CLEAN_FILE ( junk_tmp
);
3188 string objectsMacro
= GetObjectsMacro ( module
);
3189 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3190 string libsMacro
= GetLibsMacro ();
3194 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3195 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3196 targetMacro
.c_str (),
3197 objectsMacro
.c_str (),
3198 linkDepsMacro
.c_str (),
3199 backend
->GetFullPath ( *target_file
).c_str () );
3201 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
3203 if (Environment::GetArch() == "arm")
3205 fprintf ( fMakefile
,
3206 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
3207 backend
->GetFullName ( junk_tmp
).c_str (),
3208 objectsMacro
.c_str (),
3209 linkDepsMacro
.c_str (),
3210 GetLinkerMacro ().c_str ());
3214 fprintf ( fMakefile
,
3215 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
3216 backend
->GetFullName ( junk_tmp
).c_str (),
3217 objectsMacro
.c_str (),
3218 linkDepsMacro
.c_str (),
3219 GetLinkerMacro ().c_str ());
3221 fprintf ( fMakefile
,
3222 "\t${objcopy} -O binary %s $@\n",
3223 backend
->GetFullName ( junk_tmp
).c_str () );
3224 GenerateBuildMapCode ( &junk_tmp
);
3225 fprintf ( fMakefile
,
3226 "\t-@${rm} %s 2>$(NUL)\n",
3227 backend
->GetFullName ( junk_tmp
).c_str () );
3233 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
3234 const Module
& module_
)
3236 : MingwModuleHandler ( module_
)
3241 MingwBootSectorModuleHandler::Process ()
3243 GenerateBootSectorModuleTarget ();
3247 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
3249 string objectsMacro
= GetObjectsMacro ( module
);
3253 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3254 module
.name
.c_str ());
3255 fprintf ( fMakefile
,
3257 module
.name
.c_str (),
3258 objectsMacro
.c_str () );
3262 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
3263 const Module
& module_
)
3264 : MingwModuleHandler ( module_
)
3269 MingwBootProgramModuleHandler::Process ()
3271 GenerateBootProgramModuleTarget ();
3275 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3277 string
targetName ( module
.output
->name
);
3278 string
targetMacro ( GetTargetMacro (module
) );
3279 string workingDirectory
= GetWorkingDirectory ();
3280 FileLocation
junk_tmp ( TemporaryDirectory
,
3282 module
.name
+ ".junk.tmp" );
3283 FileLocation
junk_elf ( TemporaryDirectory
,
3285 module
.name
+ ".junk.elf" );
3286 FileLocation
junk_cpy ( TemporaryDirectory
,
3288 module
.name
+ ".junk.elf" );
3289 CLEAN_FILE ( junk_tmp
);
3290 CLEAN_FILE ( junk_elf
);
3291 CLEAN_FILE ( junk_cpy
);
3292 string objectsMacro
= GetObjectsMacro ( module
);
3293 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3294 string libsMacro
= GetLibsMacro ();
3295 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3299 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3300 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3301 targetMacro
.c_str (),
3302 objectsMacro
.c_str (),
3303 linkDepsMacro
.c_str (),
3304 payload
->name
.c_str (),
3305 backend
->GetFullPath ( *target_file
).c_str () );
3307 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3309 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3310 module
.buildtype
.c_str (),
3311 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3312 backend
->GetFullName ( junk_cpy
).c_str () );
3314 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3315 module
.buildtype
.c_str (),
3316 backend
->GetFullName ( junk_cpy
).c_str (),
3317 backend
->GetFullName ( junk_tmp
).c_str () );
3319 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3320 module
.buildtype
.c_str (),
3321 linkDepsMacro
.c_str (),
3322 backend
->GetFullName ( junk_tmp
).c_str (),
3323 backend
->GetFullName ( junk_elf
).c_str () );
3325 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3326 module
.buildtype
.c_str (),
3327 backend
->GetFullName ( junk_elf
).c_str (),
3328 backend
->GetFullName ( *module
.output
) .c_str () );
3330 fprintf ( fMakefile
,
3331 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3332 backend
->GetFullName ( junk_tmp
).c_str (),
3333 backend
->GetFullName ( junk_elf
).c_str (),
3334 backend
->GetFullName ( junk_cpy
).c_str () );
3340 MingwIsoModuleHandler::MingwIsoModuleHandler (
3341 const Module
& module_
)
3343 : MingwModuleHandler ( module_
)
3348 MingwIsoModuleHandler::Process ()
3350 GenerateIsoModuleTarget ();
3354 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3355 const string
& bootcdDirectory
)
3357 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3359 const Module
& m
= *module
.project
.modules
[i
];
3362 if ( m
.bootstrap
!= NULL
)
3364 FileLocation
targetFile ( OutputDirectory
,
3365 m
.bootstrap
->base
.length () > 0
3366 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3368 m
.bootstrap
->nameoncd
);
3369 OutputCopyCommand ( *m
.output
, targetFile
);
3375 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3376 const string
& bootcdDirectory
)
3378 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3380 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3381 FileLocation
targetFile ( OutputDirectory
,
3382 cdfile
.target
->relative_path
.length () > 0
3383 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3385 cdfile
.target
->name
);
3386 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3391 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3392 const string
& bootcdDirectory
)
3394 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3396 const Module
& m
= *module
.project
.modules
[i
];
3399 if ( m
.bootstrap
!= NULL
)
3401 FileLocation
targetDirectory ( OutputDirectory
,
3402 m
.bootstrap
->base
.length () > 0
3403 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3406 out
.push_back ( targetDirectory
);
3412 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3413 const string
& bootcdDirectory
)
3415 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3417 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3418 FileLocation
targetDirectory ( OutputDirectory
,
3419 cdfile
.target
->relative_path
.length () > 0
3420 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3423 out
.push_back( targetDirectory
);
3428 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3429 const string
& bootcdDirectory
)
3431 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3432 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3436 MingwIsoModuleHandler::GetBootstrapCdFiles (
3437 vector
<FileLocation
>& out
) const
3439 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3441 const Module
& m
= *module
.project
.modules
[i
];
3444 if ( m
.bootstrap
!= NULL
)
3446 out
.push_back ( *m
.output
);
3452 MingwIsoModuleHandler::GetNonModuleCdFiles (
3453 vector
<FileLocation
>& out
) const
3455 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3457 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3458 out
.push_back ( *cdfile
.source
);
3463 MingwIsoModuleHandler::GetCdFiles (
3464 vector
<FileLocation
>& out
) const
3466 GetBootstrapCdFiles ( out
);
3467 GetNonModuleCdFiles ( out
);
3471 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3473 string bootcdDirectory
= "cd";
3474 FileLocation
bootcd ( OutputDirectory
,
3477 FileLocation
bootcdReactos ( OutputDirectory
,
3478 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3480 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3481 vector
<FileLocation
> vCdDirectories
;
3484 FileLocation
srcunattend ( SourceDirectory
,
3485 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3487 FileLocation
tarunattend ( bootcdReactos
.directory
,
3488 bootcdReactos
.relative_path
,
3490 if (module
.type
== IsoRegTest
)
3491 vSourceFiles
.push_back ( srcunattend
);
3494 const Module
* bootModule
;
3495 bootModule
= module
.project
.LocateModule ( module
.type
== IsoRegTest
3498 const FileLocation
*isoboot
= bootModule
->output
;
3499 vSourceFiles
.push_back ( *isoboot
);
3501 // prepare reactos.dff and reactos.inf
3502 FileLocation
reactosDff ( SourceDirectory
,
3503 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3505 FileLocation
reactosInf ( bootcdReactos
.directory
,
3506 bootcdReactos
.relative_path
,
3508 FileLocation
vgafontsCab( bootcdReactos
.directory
,
3509 bootcdReactos
.relative_path
,
3511 FileLocation
vgafontsDir( SourceDirectory
,
3512 "media" + sSep
+ "vgafonts",
3515 vSourceFiles
.push_back ( reactosDff
);
3519 if (module
.type
== IsoRegTest
)
3520 IsoName
= "ReactOS-RegTest.iso";
3522 IsoName
= "ReactOS.iso";
3525 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3528 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3529 GetCdFiles ( vCdFiles
);
3530 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3531 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3533 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3534 module
.name
.c_str ());
3535 fprintf ( fMakefile
,
3536 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3537 module
.name
.c_str (),
3538 backend
->GetFullName ( *isoboot
).c_str (),
3539 sourceFiles
.c_str (),
3541 cdDirectories
.c_str () );
3542 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3543 fprintf ( fMakefile
,
3544 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s %s\\*.bin\n", // Escape the asterisk for Make
3545 backend
->GetFullName ( vgafontsCab
).c_str (),
3546 backend
->GetFullName ( vgafontsDir
).c_str ());
3547 fprintf ( fMakefile
,
3548 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3549 backend
->GetFullName ( reactosDff
).c_str (),
3550 backend
->GetFullPath ( bootcdReactos
).c_str () );
3551 fprintf ( fMakefile
,
3552 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3553 backend
->GetFullName ( reactosDff
).c_str (),
3554 backend
->GetFullName ( reactosInf
).c_str (),
3555 backend
->GetFullPath ( bootcdReactos
).c_str ());
3556 fprintf ( fMakefile
,
3557 "\t-@${rm} %s 2>$(NUL)\n",
3558 backend
->GetFullName ( reactosInf
).c_str () );
3559 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3560 OutputCdfileCopyCommands ( bootcdDirectory
);
3562 if (module
.type
== IsoRegTest
)
3563 OutputCopyCommand ( srcunattend
, tarunattend
);
3565 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3566 fprintf ( fMakefile
,
3567 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3568 backend
->GetFullName ( *isoboot
).c_str (),
3569 backend
->GetFullPath ( bootcd
).c_str (),
3571 fprintf ( fMakefile
,
3576 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3577 const Module
& module_
)
3579 : MingwModuleHandler ( module_
)
3584 MingwLiveIsoModuleHandler::Process ()
3586 GenerateLiveIsoModuleTarget ();
3590 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3592 FileLocation
dir ( OutputDirectory
,
3595 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3599 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3600 string
& reactosDirectory
)
3602 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3604 const Module
& m
= *module
.project
.modules
[i
];
3609 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3610 FileLocation
destination ( OutputDirectory
,
3611 m
.install
->relative_path
.length () > 0
3612 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3613 : livecdDirectory
+ sSep
+ reactosDirectory
,
3615 OutputCopyCommand ( *aliasedModule
.output
,
3622 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3623 string
& reactosDirectory
)
3625 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3627 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3628 FileLocation
target ( OutputDirectory
,
3629 installfile
.target
->relative_path
.length () > 0
3630 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3631 : livecdDirectory
+ sSep
+ reactosDirectory
,
3632 installfile
.target
->name
);
3633 OutputCopyCommand ( *installfile
.source
, target
);
3638 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3640 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3641 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3642 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3643 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3644 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3645 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3647 FileLocation
livecdIni ( SourceDirectory
,
3648 "boot" + sSep
+ "bootdata",
3650 FileLocation
destination ( OutputDirectory
,
3653 OutputCopyCommand ( livecdIni
,
3658 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3660 FileLocation
freeldr ( OutputDirectory
,
3661 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3663 FileLocation
destination ( OutputDirectory
,
3664 livecdDirectory
+ sSep
+ "loader",
3666 OutputCopyCommand ( freeldr
,
3671 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3673 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3674 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3676 fprintf ( fMakefile
,
3677 "\t$(ECHO_MKHIVE)\n" );
3678 fprintf ( fMakefile
,
3679 "\t$(MKHIVE_TARGET) boot%cbootdata %s boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst.inf\n",
3680 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3681 cSep
, cSep
, cSep
, cSep
);
3685 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3687 string livecdDirectory
= module
.name
;
3688 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3692 const Module
* bootModule
;
3693 bootModule
= module
.project
.LocateModule ( module
.name
== "livecdregtest"
3696 const FileLocation
*isoboot
= bootModule
->output
;
3697 if (module
.name
== "livecdregtest")
3698 IsoName
= "ReactOS-LiveCD-RegTest.iso";
3700 IsoName
= "ReactOS-LiveCD.iso";
3702 string reactosDirectory
= "reactos";
3703 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3704 FileLocation
livecdReactos ( OutputDirectory
,
3705 livecdReactosNoFixup
,
3707 CLEAN_FILE ( livecdReactos
);
3709 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3710 module
.name
.c_str ());
3711 fprintf ( fMakefile
,
3712 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3713 module
.name
.c_str (),
3714 backend
->GetFullName ( *isoboot
) .c_str (),
3715 backend
->GetFullPath ( livecdReactos
).c_str () );
3716 OutputModuleCopyCommands ( livecdDirectory
,
3718 OutputNonModuleCopyCommands ( livecdDirectory
,
3720 OutputProfilesDirectoryCommands ( livecdDirectory
);
3721 OutputLoaderCommands ( livecdDirectory
);
3722 OutputRegistryCommands ( livecdDirectory
);
3723 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3724 fprintf ( fMakefile
,
3725 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3726 backend
->GetFullName( *isoboot
).c_str (),
3727 backend
->GetFullPath ( livecd
).c_str (),
3729 fprintf ( fMakefile
,
3734 MingwTestModuleHandler::MingwTestModuleHandler (
3735 const Module
& module_
)
3737 : MingwModuleHandler ( module_
)
3742 MingwTestModuleHandler::Process ()
3744 GenerateTestModuleTarget ();
3747 /* caller needs to delete the returned object */
3749 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3751 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3752 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3753 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3757 MingwTestModuleHandler::GenerateTestModuleTarget ()
3759 string
targetMacro ( GetTargetMacro ( module
) );
3760 string workingDirectory
= GetWorkingDirectory ( );
3761 string objectsMacro
= GetObjectsMacro ( module
);
3762 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3763 string libsMacro
= GetLibsMacro ();
3765 GenerateImportLibraryTargetIfNeeded ();
3767 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3771 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3774 if ( module
.cplusplus
)
3779 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3780 module
.GetEntryPoint(true).c_str (),
3781 module
.baseaddress
.c_str () );
3782 GenerateLinkerCommand ( dependencies
,
3791 GeneratePhonyTarget();
3796 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
3797 const Module
& module_
)
3799 : MingwModuleHandler ( module_
)
3804 MingwRpcServerModuleHandler::Process ()
3810 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
3811 const Module
& module_
)
3813 : MingwModuleHandler ( module_
)
3818 MingwRpcClientModuleHandler::Process ()
3824 MingwRpcProxyModuleHandler::MingwRpcProxyModuleHandler (
3825 const Module
& module_
)
3827 : MingwModuleHandler ( module_
)
3832 MingwRpcProxyModuleHandler::Process ()
3838 MingwAliasModuleHandler::MingwAliasModuleHandler (
3839 const Module
& module_
)
3841 : MingwModuleHandler ( module_
)
3846 MingwAliasModuleHandler::Process ()
3850 MingwIdlHeaderModuleHandler::MingwIdlHeaderModuleHandler (
3851 const Module
& module_
)
3853 : MingwModuleHandler ( module_
)
3858 MingwIdlHeaderModuleHandler::Process ()
3863 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3864 const Module
& module_
)
3866 : MingwModuleHandler ( module_
)
3871 MingwElfExecutableModuleHandler::Process ()
3873 string
targetName ( module
.output
->name
);
3874 string
targetMacro ( GetTargetMacro (module
) );
3875 string workingDirectory
= GetWorkingDirectory ();
3876 string objectsMacro
= GetObjectsMacro ( module
);
3877 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3878 string libsMacro
= GetLibsMacro ();
3882 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3883 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3884 targetMacro
.c_str (),
3885 objectsMacro
.c_str (),
3886 linkDepsMacro
.c_str (),
3887 backend
->GetFullPath ( *target_file
).c_str () );
3889 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3891 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3892 module
.buildtype
.c_str(),
3893 objectsMacro
.c_str(),
3895 targetMacro
.c_str () );