2 * Copyright (C) 2005 Casper S. Hornstrup
3 * 2007-2008 Hervé Poussineau
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "../../pch.h"
23 #include "../../rbuild.h"
25 #include "modulehandler.h"
32 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
33 #define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
36 MingwModuleHandler::backend
= NULL
;
38 MingwModuleHandler::fMakefile
= NULL
;
42 const string
& filename
,
43 const string
& prefix
)
45 if ( !prefix
.length() )
48 const char* pfilename
= filename
.c_str();
49 const char* p1
= strrchr ( pfilename
, '/' );
50 const char* p2
= strrchr ( pfilename
, '\\' );
55 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
58 out
+= prefix
+ pfilename
;
63 GetTargetMacro ( const Module
& module
, bool with_dollar
)
65 string
s ( module
.name
);
69 return ssprintf ( "$(%s)", s
.c_str() );
73 MingwModuleHandler::MingwModuleHandler (
74 const Module
& module_
)
81 MingwModuleHandler::~MingwModuleHandler()
86 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
92 MingwModuleHandler::SetMakefile ( FILE* f
)
98 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
103 /*static*/ const FileLocation
*
104 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
106 switch ( file
->directory
)
108 case SourceDirectory
:
110 case IntermediateDirectory
:
111 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
113 case OutputDirectory
:
114 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
116 case InstallDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
120 throw InvalidOperationException ( __FILE__
,
122 "Invalid directory %d.",
129 /* caller needs to delete the returned object */
131 MingwModuleHandler::GetTargetFilename (
132 const Module
& module
,
133 string_list
* pclean_files
)
135 FileLocation
*target
= new FileLocation ( *module
.output
);
138 string_list
& clean_files
= *pclean_files
;
139 CLEAN_FILE ( *target
);
144 /* caller needs to delete the returned object */
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 FileLocation
*target
= new FileLocation ( *module
.dependency
);
153 string_list
& clean_files
= *pclean_files
;
154 CLEAN_FILE ( *target
);
159 /* caller needs to delete the returned object */
161 MingwModuleHandler::InstanciateHandler (
162 const Module
& module
,
163 MingwBackend
* backend
)
165 MingwModuleHandler
* handler
;
166 switch ( module
.type
)
169 case HostStaticLibrary
:
176 case EmbeddedTypeLib
:
178 handler
= new MingwModuleHandler( module
);
181 handler
= new MingwBuildToolModuleHandler ( module
);
184 handler
= new MingwKernelModuleHandler ( module
);
187 handler
= new MingwNativeCUIModuleHandler ( module
);
190 handler
= new MingwWin32CUIModuleHandler ( module
);
194 handler
= new MingwWin32GUIModuleHandler ( module
);
198 case KernelModeDriver
:
199 handler
= new MingwKernelModeDLLModuleHandler ( module
);
202 handler
= new MingwNativeDLLModuleHandler ( module
);
205 handler
= new MingwWin32DLLModuleHandler ( module
);
208 handler
= new MingwWin32OCXModuleHandler ( module
);
211 handler
= new MingwBootLoaderModuleHandler ( module
);
214 handler
= new MingwBootProgramModuleHandler ( module
);
217 handler
= new MingwIsoModuleHandler ( module
);
220 handler
= new MingwLiveIsoModuleHandler ( module
);
223 handler
= new MingwIsoModuleHandler ( module
);
226 handler
= new MingwLiveIsoModuleHandler ( module
);
229 handler
= new MingwTestModuleHandler ( module
);
232 handler
= new MingwAliasModuleHandler ( module
);
235 handler
= new MingwCabinetModuleHandler ( module
);
238 handler
= new MingwElfExecutableModuleHandler ( module
);
241 throw UnknownModuleTypeException (
242 module
.node
.location
,
250 MingwModuleHandler::GetWorkingDirectory () const
256 MingwModuleHandler::GetBasename ( const string
& filename
) const
258 size_t index
= filename
.find_last_of ( '.' );
259 if ( index
!= string::npos
)
260 return filename
.substr ( 0, index
);
265 MingwModuleHandler::GetCompilationUnitDependencies (
266 const CompilationUnit
& compilationUnit
) const
268 if ( compilationUnit
.GetFiles ().size () <= 1 )
270 vector
<string
> sourceFiles
;
271 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
273 const File
& file
= *compilationUnit
.GetFiles ()[i
];
274 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
276 return string ( " " ) + v2s ( sourceFiles
, 10 );
279 /* caller needs to delete the returned object */
281 MingwModuleHandler::GetModuleArchiveFilename () const
283 if ( IsStaticLibrary ( module
) )
284 return GetTargetFilename ( module
, NULL
);
285 return new FileLocation ( IntermediateDirectory
,
286 module
.output
->relative_path
,
287 ReplaceExtension ( module
.name
, ".temp.a" ) );
291 MingwModuleHandler::ReferenceObjects (
292 const Module
& module
)
294 if ( module
.type
== ObjectLibrary
)
296 if ( module
.type
== RpcServer
)
298 if ( module
.type
== RpcClient
)
300 if ( module
.type
== RpcProxy
)
302 if ( module
.type
== IdlHeader
)
304 if ( module
.type
== MessageHeader
)
310 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
311 const FileLocation
& destination
)
313 fprintf ( fMakefile
, "# OUTPUT COPY COMMAND\n" );
317 "\t${cp} %s %s 1>$(NUL)\n",
318 backend
->GetFullName ( source
).c_str (),
319 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
323 MingwModuleHandler::GetImportLibraryDependency (
324 const Module
& importedModule
)
327 if ( ReferenceObjects ( importedModule
) )
329 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
332 dep
= GetTargetMacro ( importedModule
);
333 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
335 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
336 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
337 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
338 if ( GetExtension ( *objectFilename
) == ".h" )
339 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
340 else if ( GetExtension ( *objectFilename
) == ".rc" )
341 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
346 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
347 dep
= backend
->GetFullName ( *library_target
);
348 delete library_target
;
351 if ( IsStaticLibrary ( importedModule
) || importedModule
.type
== ObjectLibrary
)
353 const std::vector
<Library
*>& libraries
= importedModule
.non_if_data
.libraries
;
355 for ( size_t i
= 0; i
< libraries
.size (); ++ i
)
358 dep
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
366 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
367 string_list
& targets
)
369 if ( dependencyModule
.invocations
.size () > 0 )
371 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
373 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
374 invoke
.GetTargets ( targets
);
378 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
382 MingwModuleHandler::GetModuleDependencies (
383 string_list
& dependencies
)
385 size_t iend
= module
.dependencies
.size ();
390 for ( size_t i
= 0; i
< iend
; i
++ )
392 const Dependency
& dependency
= *module
.dependencies
[i
];
393 const Module
& dependencyModule
= *dependency
.dependencyModule
;
394 GetTargets ( dependencyModule
,
397 vector
<FileLocation
> v
;
398 GetDefinitionDependencies ( v
);
400 for ( size_t i
= 0; i
< v
.size (); i
++ )
402 const FileLocation
& file
= v
[i
];
403 dependencies
.push_back ( backend
->GetFullName ( file
) );
407 /* caller needs to delete the returned object */
409 MingwModuleHandler::GetObjectFilename (
410 const FileLocation
* sourceFile
,
411 const Module
& module
) const
413 DirectoryLocation destination_directory
;
415 string extension
= GetExtension ( *sourceFile
);
417 if ( module
.type
== BootSector
)
418 return new FileLocation ( *module
.output
);
419 else if (extension
== ".rc")
420 newExtension
= "_" + module
.name
+ ".coff";
421 else if (extension
== ".mc")
422 newExtension
= ".rc";
423 else if (extension
== ".idl")
425 if ( module
.type
== RpcServer
)
426 newExtension
= "_s.o";
427 else if ( module
.type
== RpcClient
)
428 newExtension
= "_c.o";
429 else if ( module
.type
== RpcProxy
)
430 newExtension
= "_p.o";
435 newExtension
= "_" + module
.name
+ ".o";
437 if ( module
.type
== BootSector
)
438 destination_directory
= OutputDirectory
;
440 destination_directory
= IntermediateDirectory
;
442 const FileLocation
*obj_file
= new FileLocation(
443 destination_directory
,
444 sourceFile
->relative_path
,
445 ReplaceExtension ( sourceFile
->name
, newExtension
) );
446 PassThruCacheDirectory ( obj_file
);
452 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
454 return module
.name
+ "_clean";
458 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
460 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
462 Library
& library
= *module
.non_if_data
.libraries
[i
];
463 if ( library
.importedModule
->type
== ObjectLibrary
)
464 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
469 MingwModuleHandler::GenerateCleanTarget () const
471 if ( module
.type
== Alias
)
474 fprintf ( fMakefile
, "# CLEAN TARGET\n" );
476 ".PHONY: %s_clean\n",
477 module
.name
.c_str() );
478 vector
<string
> referencedModuleNames
;
479 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
482 GetModuleCleanTarget ( module
).c_str(),
483 v2s ( referencedModuleNames
, 10 ).c_str () );
484 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
486 if ( ( i
+ 1 ) % 10 == 9 )
487 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
488 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
490 fprintf ( fMakefile
, " 2>$(NUL)\n" );
492 if( ProxyMakefile::GenerateProxyMakefile(module
) )
494 DirectoryLocation root
;
496 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
497 root
= SourceDirectory
;
499 root
= OutputDirectory
;
501 FileLocation
proxyMakefile ( root
,
502 module
.output
->relative_path
,
504 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
505 backend
->GetFullName ( proxyMakefile
).c_str () );
508 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
512 MingwModuleHandler::GenerateInstallTarget () const
514 if ( !module
.install
)
516 fprintf ( fMakefile
, "# INSTALL TARGET\n" );
517 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
520 module
.name
.c_str (),
521 backend
->GetFullName ( *module
.install
).c_str () );
525 MingwModuleHandler::GenerateDependsTarget () const
527 fprintf ( fMakefile
, "# DEPENDS TARGET\n" );
529 ".PHONY: %s_depends\n",
530 module
.name
.c_str() );
532 "%s_depends: $(RBUILD_TARGET)\n",
533 module
.name
.c_str () );
535 "\t$(ECHO_RBUILD)\n" );
537 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
538 module
.name
.c_str () );
542 MingwModuleHandler::GenerateGccDefineParametersFromVector (
543 const vector
<Define
*>& defines
,
544 set
<string
>& used_defs
)
548 for ( size_t i
= 0; i
< defines
.size (); i
++ )
550 Define
& define
= *defines
[i
];
551 if (used_defs
.find(define
.name
) != used_defs
.end())
553 if (parameters
.length () > 0)
555 if (define
.name
.find('(') != string::npos
)
556 parameters
+= "$(QT)";
558 parameters
+= define
.name
;
559 if (define
.value
.length () > 0)
562 parameters
+= define
.value
;
564 if (define
.name
.find('(') != string::npos
)
565 parameters
+= "$(QT)";
566 used_defs
.insert(used_defs
.begin(),define
.name
);
572 MingwModuleHandler::ConcatenatePaths (
574 const string
& path2
) const
576 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
578 if ( path1
[path1
.length ()] == cSep
)
579 return path1
+ path2
;
581 return path1
+ cSep
+ path2
;
585 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
587 string parameters
, path_prefix
;
588 for ( size_t i
= 0; i
< includes
.size (); i
++ )
590 Include
& include
= *includes
[i
];
591 if ( parameters
.length () > 0 )
593 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);
599 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
602 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
604 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
605 if ( compilerFlag
.compiler
== type
)
606 parameters
+= " " + compilerFlag
.flag
;
612 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
615 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
617 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
618 if ( parameters
.length () > 0 )
620 parameters
+= linkerFlag
.flag
;
626 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
627 const vector
<Library
*>& libraries
)
629 string
dependencies ( "" );
631 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
633 if ( wrap_count
++ == 5 )
634 dependencies
+= " \\\n\t\t", wrap_count
= 0;
635 else if ( dependencies
.size () > 0 )
637 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
643 MingwModuleHandler::GenerateLinkerParameters () const
645 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
649 MingwModuleHandler::GenerateMacro (
650 const char* assignmentOperation
,
652 const IfableData
& data
,
653 set
<const Define
*> *used_defs
,
654 bool generatingCompilerMacro
)
657 bool generateAssignment
;
659 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
660 if ( generatingCompilerMacro
)
661 generateAssignment
|= data
.compilerFlags
.size () > 0;
662 if ( generateAssignment
)
667 assignmentOperation
);
670 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
675 backend
->GetFullPath ( *pchFilename
).c_str () );
679 if ( generatingCompilerMacro
)
681 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
682 if ( compilerParameters
.size () > 0 )
687 compilerParameters
.c_str () );
690 for ( i
= 0; i
< data
.includes
.size(); i
++ )
692 const Include
& include
= *data
.includes
[i
];
693 const FileLocation
* includeDirectory
= include
.directory
;
697 backend
->GetFullPath ( *includeDirectory
).c_str() );
699 for ( i
= 0; i
< data
.defines
.size(); i
++ )
701 const Define
& define
= *data
.defines
[i
];
704 set
<const Define
*>::const_iterator last_define
;
705 for (last_define
= used_defs
->begin ();
706 last_define
!= used_defs
->end ();
709 if ( (*last_define
)->name
!= define
.name
)
711 if ( !define
.overridable
)
713 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
715 "Invalid override of define '%s', already defined at %s",
716 define
.name
.c_str (),
717 define
.node
->location
.c_str () );
719 if ( backend
->configuration
.Verbose
)
720 printf("%s: Overriding '%s' already defined at %s\n",
721 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
722 define
.node
->location
.c_str () );
725 if ( last_define
!= used_defs
->end () )
731 define
.name
.c_str() );
732 if (define
.value
.length () > 0)
736 define
.value
.c_str() );
738 used_defs
->insert( used_defs
->begin (), &define
);
740 if ( generateAssignment
)
742 fprintf ( fMakefile
, "\n" );
747 MingwModuleHandler::GenerateMacros (
748 const char* assignmentOperation
,
749 const IfableData
& data
,
750 const vector
<LinkerFlag
*>* linkerFlags
,
751 set
<const Define
*>& used_defs
)
753 fprintf ( fMakefile
, "# MACROS\n" );
754 GenerateMacro ( assignmentOperation
,
759 GenerateMacro ( assignmentOperation
,
765 if ( linkerFlags
!= NULL
)
767 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
768 if ( linkerParameters
.size () > 0 )
773 linkerflagsMacro
.c_str (),
775 linkerParameters
.c_str() );
779 if ( data
.libraries
.size () > 0 )
781 // Check if host and target modules are not mixed up
782 HostType current
= ModuleHandlerInformations
[module
.type
].DefaultHost
;
783 std::vector
<Library
*>::const_iterator it
;
784 for ( it
= data
.libraries
.begin(); it
!= data
.libraries
.end(); ++it
)
786 HostType imported
= ModuleHandlerInformations
[(*it
)->importedModule
->type
].DefaultHost
;
787 if (current
!= imported
)
789 throw InvalidOperationException ( __FILE__
,
791 "Module '%s' imports module '%s', which is not of the right type",
792 module
.name
.c_str (),
793 (*it
)->importedModule
->name
.c_str () );
797 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
798 if ( deps
.size () > 0 )
811 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
813 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
814 delete compilationUnits
[i
];
818 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
823 MingwModuleHandler::GenerateSourceMacros (
824 const IfableData
& data
)
828 fprintf ( fMakefile
, "# SOURCE MACROS\n" );
829 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
830 vector
<const FileLocation
*> headers
;
831 if ( compilationUnits
.size () > 0 )
836 sourcesMacro
.c_str () );
837 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
839 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
840 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
844 ( i
%10 == 9 ? " \\\n\t" : " " ),
845 backend
->GetFullName ( compilationName
).c_str () );
847 fprintf ( fMakefile
, "\n" );
850 vector
<CompilationUnit
*> sourceCompilationUnits
;
851 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
852 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
854 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
858 sourcesMacro
.c_str(),
859 backend
->GetFullName ( compilationName
).c_str () );
861 CleanupCompilationUnitVector ( sourceCompilationUnits
);
865 MingwModuleHandler::GenerateObjectMacros (
866 const IfableData
& data
)
869 const char* assignmentOperation
= "=";
871 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
872 vector
<const FileLocation
*> headers
;
873 vector
<const FileLocation
*> mcheaders
;
874 vector
<const FileLocation
*> mcresources
;
875 fprintf ( fMakefile
, "# OBJECT MACROS\n" );
876 if ( compilationUnits
.size () > 0 )
878 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
880 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
881 if ( compilationUnit
.IsFirstFile () )
883 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
884 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
887 objectsMacro
.c_str(),
888 backend
->GetFullName ( *object_file
).c_str () );
890 assignmentOperation
= "+=";
897 objectsMacro
.c_str (),
898 assignmentOperation
);
899 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
901 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
902 if ( !compilationUnit
.IsFirstFile () )
904 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
905 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
906 if ( GetExtension ( *objectFilename
) == ".h" )
907 headers
.push_back ( objectFilename
);
908 else if ( GetExtension ( *objectFilename
) == ".rc" )
910 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
911 mcheaders
.push_back ( headerFilename
);
912 mcresources
.push_back ( objectFilename
);
919 ( i
%10 == 9 ? " \\\n\t" : " " ),
920 backend
->GetFullName ( *objectFilename
).c_str () );
921 delete objectFilename
;
925 fprintf ( fMakefile
, "\n" );
927 if ( headers
.size () > 0 )
932 module
.name
.c_str (),
933 assignmentOperation
);
934 for ( i
= 0; i
< headers
.size (); i
++ )
939 ( i
%10 == 9 ? " \\\n\t" : " " ),
940 backend
->GetFullName ( *headers
[i
] ).c_str () );
943 fprintf ( fMakefile
, "\n" );
946 if ( mcheaders
.size () > 0 )
951 module
.name
.c_str (),
952 assignmentOperation
);
953 for ( i
= 0; i
< mcheaders
.size (); i
++ )
958 ( i
%10 == 9 ? " \\\n\t" : " " ),
959 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
962 fprintf ( fMakefile
, "\n" );
965 if ( mcresources
.size () > 0 )
970 module
.name
.c_str (),
971 assignmentOperation
);
972 for ( i
= 0; i
< mcresources
.size (); i
++ )
977 ( i
%10 == 9 ? " \\\n\t" : " " ),
978 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
979 delete mcresources
[i
];
981 fprintf ( fMakefile
, "\n" );
984 vector
<CompilationUnit
*> sourceCompilationUnits
;
985 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
986 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
988 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
989 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
993 objectsMacro
.c_str(),
994 backend
->GetFullName ( *object_file
).c_str () );
997 CleanupCompilationUnitVector ( sourceCompilationUnits
);
999 if ( IsSpecDefinitionFile() )
1001 const FileLocation
*stubs_file
= new FileLocation(
1002 IntermediateDirectory
,
1003 module
.importLibrary
->source
->relative_path
,
1004 ReplaceExtension ( module
.importLibrary
->source
->name
, "_" + module
.name
+ ".stubs.o" ) );
1009 objectsMacro
.c_str(),
1010 backend
->GetFullName ( *stubs_file
).c_str () );
1015 if ( module
.type
== RpcProxy
)
1017 const FileLocation
*dlldata_file
= GetDlldataFilename();
1022 objectsMacro
.c_str(),
1023 ReplaceExtension ( backend
->GetFullName ( *dlldata_file
), ".o" ).c_str() );
1025 delete dlldata_file
;
1030 MingwModuleHandler::GetDlldataFilename() const
1032 std::string dlldata_path
= "";
1033 size_t dlldata_path_len
= module
.xmlbuildFile
.find_last_of(cSep
);
1035 if ( dlldata_path_len
!= std::string::npos
&& dlldata_path_len
!= 0 )
1036 dlldata_path
= module
.xmlbuildFile
.substr(0, dlldata_path_len
);
1038 return new FileLocation( IntermediateDirectory
, dlldata_path
, module
.name
+ ".dlldata.c" );
1041 /* caller needs to delete the returned object */
1043 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1045 if ( !module
.pch
|| !use_pch
)
1047 return new FileLocation ( IntermediateDirectory
,
1048 module
.pch
->file
->relative_path
+ "/.gch_" + module
.name
,
1049 module
.pch
->file
->name
+ ".gch" );
1052 Rule
arRule1 ( "$(intermediate_path_noext).a: $($(module_name)_OBJS) $(dependencies) | $(intermediate_dir)\n",
1053 "$(intermediate_path_noext).a",
1054 "$(intermediate_dir)$(SEP)", NULL
);
1055 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1056 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1058 Rule
arHostRule2 ( "\t$(ECHO_HOSTAR)\n"
1059 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1061 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1062 "ifeq ($(ROS_BUILDDEPS),full)\n"
1063 "$(intermediate_path_unique).o.d: $(source) | $(intermediate_dir)\n"
1064 "\t$(ECHO_DEPENDS)\n"
1065 "\t${gcc} -x assembler-with-cpp -MF $@ -D__ASM__ $($(module_name)_CFLAGS) -M -MP -MT $@ $<\n"
1066 "-include $(intermediate_path_unique).o.d\n"
1068 "$(intermediate_path_unique).o: $(source)$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_unique).o.d) $(dependencies) | $(intermediate_dir)\n"
1070 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1071 "$(intermediate_path_unique).o",
1072 "$(intermediate_path_unique).o.d",
1073 "$(intermediate_dir)$(SEP)", NULL
);
1074 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1075 "$(module_output): $(source) $(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1077 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1078 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1079 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1080 "$(intermediate_path_unique).o: $(source) $(dependencies) | $(intermediate_dir)\n"
1082 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1083 "$(intermediate_path_unique).o",
1084 "$(intermediate_dir)$(SEP)", NULL
);
1085 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1086 "ifeq ($(ROS_BUILDDEPS),full)\n"
1087 "$(intermediate_path_unique).coff.d: $(source) | $(intermediate_dir) $(TEMPORARY)\n"
1088 "\t$(ECHO_DEPENDS)\n"
1089 "\t${gcc} -xc -M -MP -MT $@ -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) -MF $@\n"
1090 "-include $(intermediate_path_unique).coff.d\n"
1092 "$(intermediate_path_unique).coff: $(source)$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_unique).coff.d) $(dependencies) $(WRC_TARGET) | $(intermediate_dir) $(TEMPORARY)\n"
1094 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1095 "\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"
1096 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1097 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1098 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1099 "$(intermediate_path_unique).coff",
1100 "$(intermediate_path_unique).coff.d",
1101 "$(intermediate_dir)$(SEP)", NULL
);
1102 Rule
wmcRule ( "$(intermediate_path_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(WMC_TARGET) $(source) | $(intermediate_dir)\n"
1104 "\t$(Q)$(WMC_TARGET) -i -H $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h -o $(intermediate_path_noext).rc $(source)\n",
1105 "$(intermediate_path_noext).rc",
1106 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1107 "$(intermediate_dir)$(SEP)", NULL
);
1108 Rule
winebuildPDefRule ( "ifeq ($(ROS_BUILDDEPS),full)\n"
1109 "$(intermediate_path_unique).spec.d: $(source) | $(intermediate_dir)\n"
1110 "\t$(ECHO_DEPENDS)\n"
1111 "\t${gcc} -xc -M -MP -MT $@ ${$(module_name)_RCFLAGS} $(source) -MF $@\n\n"
1112 "-include $(intermediate_path_unique).spec.d\n"
1114 "$(intermediate_path_unique).spec: $(source)$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_unique).spec.d) $(dependencies) | $(intermediate_dir)\n"
1116 "\t${gcc} -xc -E ${$(module_name)_RCFLAGS} $(source) > $(intermediate_path_unique).spec\n\n"
1117 "$(intermediate_path_unique).auto.def: $(intermediate_path_unique).spec $(WINEBUILD_TARGET) | $(intermediate_dir)\n"
1118 "\t$(ECHO_WINEBLD)\n"
1119 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(intermediate_path_unique).auto.def --def -E $(intermediate_path_unique).spec --filename $(module_dllname)\n\n",
1120 "$(intermediate_path_unique).spec",
1121 "$(intermediate_path_unique).spec.d",
1122 "$(intermediate_path_unique).auto.def",
1123 "$(intermediate_dir)$(SEP)", NULL
);
1124 Rule
winebuildPRule ( "$(intermediate_path_unique).stubs.c: $(intermediate_path_unique).spec $(WINEBUILD_TARGET) | $(intermediate_dir)\n"
1125 "\t$(ECHO_WINEBLD)\n"
1126 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(intermediate_path_unique).spec --filename $(module_dllname)\n\n"
1127 "ifeq ($(ROS_BUILDDEPS),full)\n"
1128 "$(intermediate_path_unique).stubs.o.d: $(intermediate_path_unique).stubs.c | $(intermediate_dir)\n"
1129 "\t$(ECHO_DEPENDS)\n"
1130 "\t${gcc} -MF $@ $($(module_name)_CFLAGS)$(compiler_flags) -M -MP -MT $@ $<\n"
1131 "-include $(intermediate_path_unique).stubs.o.d\n"
1133 "$(intermediate_path_unique).stubs.o: $(intermediate_path_unique).stubs.c$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_unique).stubs.o.d) | $(intermediate_dir)\n"
1135 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1136 "$(intermediate_path_unique).spec",
1137 "$(intermediate_path_unique).stubs.c",
1138 "$(intermediate_path_unique).stubs.o",
1139 "$(intermediate_path_unique).stubs.o.d",
1140 "$(intermediate_dir)$(SEP)", NULL
);
1141 Rule
winebuildDefRule ( "$(intermediate_path_unique).auto.def: $(source) $(dependencies) $(WINEBUILD_TARGET) | $(intermediate_dir)\n"
1142 "\t$(ECHO_WINEBLD)\n"
1143 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(intermediate_path_unique).auto.def --def -E $(source) --filename $(module_dllname)\n\n",
1144 "$(intermediate_path_noext).spec",
1145 "$(intermediate_path_unique).auto.def",
1146 "$(intermediate_dir)$(SEP)", NULL
);
1147 Rule
winebuildRule ( "$(intermediate_path_unique).stubs.c: $(source) $(WINEBUILD_TARGET)\n"
1148 "\t$(ECHO_WINEBLD)\n"
1149 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(source) --filename $(module_dllname)\n"
1150 "ifeq ($(ROS_BUILDDEPS),full)\n"
1151 "$(intermediate_path_unique).stubs.o.d: $(intermediate_path_unique).stubs.c | $(intermediate_dir)\n"
1152 "\t$(ECHO_DEPENDS)\n"
1153 "\t${gcc} -MF $@ $($(module_name)_CFLAGS)$(compiler_flags) -M -MP -MT $@ $<\n"
1154 "-include $(intermediate_path_unique).stubs.o.d\n"
1156 "$(intermediate_path_unique).stubs.o: $(intermediate_path_unique).stubs.c$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_unique).stubs.o.d) $(dependencies) | $(intermediate_dir)\n"
1158 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1159 "$(intermediate_path_unique).stubs.c",
1160 "$(intermediate_path_unique).stubs.o",
1161 "$(intermediate_path_unique).stubs.o.d",
1162 "$(intermediate_dir)$(SEP)", NULL
);
1163 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1164 "$(intermediate_path_noext).h: $(source) $(dependencies) $(WIDL_TARGET) | $(intermediate_dir)\n"
1166 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(intermediate_path_noext).h $(source)\n",
1167 "$(intermediate_path_noext).h",
1168 "$(intermediate_dir)$(SEP)", NULL
);
1169 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1170 "$(intermediate_path_noext)_s.c $(intermediate_path_noext)_s.h: $(source) $(dependencies) $(WIDL_TARGET) | $(intermediate_dir)\n"
1172 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(intermediate_path_noext)_s.h -s -S $(intermediate_path_noext)_s.c $(source)\n"
1173 "ifeq ($(ROS_BUILDDEPS),full)\n"
1174 "$(intermediate_path_noext)_s.o.d: $(intermediate_path_noext)_s.c | $(intermediate_dir)\n"
1175 "\t$(ECHO_DEPENDS)\n"
1176 "\t${gcc} -MF $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -M -MP -MT $@ $<\n"
1177 "-include $(intermediate_path_noext)_s.o.d\n"
1179 "$(intermediate_path_noext)_s.o: $(intermediate_path_noext)_s.c $(intermediate_path_noext)_s.h$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_noext)_s.o.d) $(dependencies) | $(intermediate_dir)\n"
1181 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1182 "$(intermediate_path_noext)_s.h",
1183 "$(intermediate_path_noext)_s.c",
1184 "$(intermediate_path_noext)_s.o",
1185 "$(intermediate_path_noext)_s.o.d",
1186 "$(intermediate_dir)$(SEP)", NULL
);
1187 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1188 "$(intermediate_path_noext)_c.c $(intermediate_path_noext)_c.h: $(source) $(dependencies) $(WIDL_TARGET) | $(intermediate_dir)\n"
1190 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(intermediate_path_noext)_c.h -c -C $(intermediate_path_noext)_c.c $(source)\n"
1191 "ifeq ($(ROS_BUILDDEPS),full)\n"
1192 "$(intermediate_path_noext)_c.o.d: $(intermediate_path_noext)_c.c | $(intermediate_dir)\n"
1193 "\t$(ECHO_DEPENDS)\n"
1194 "\t${gcc} -MF $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -M -MP -MT $@ $<\n"
1195 "-include $(intermediate_path_noext)_c.o.d\n"
1197 "$(intermediate_path_noext)_c.o: $(intermediate_path_noext)_c.c $(intermediate_path_noext)_c.h$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_noext)_c.o.d) $(dependencies) | $(intermediate_dir)\n"
1199 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1200 "$(intermediate_path_noext)_c.h",
1201 "$(intermediate_path_noext)_c.c",
1202 "$(intermediate_path_noext)_c.o",
1203 "$(intermediate_path_noext)_c.o.d",
1204 "$(intermediate_dir)$(SEP)", NULL
);
1205 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1206 "$(intermediate_path_noext)_p.c $(intermediate_path_noext)_p.h: $(source) $(dependencies) $(WIDL_TARGET) | $(intermediate_dir)\n"
1208 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(intermediate_path_noext)_p.h -p -P $(intermediate_path_noext)_p.c $(source)\n"
1209 "ifeq ($(ROS_BUILDDEPS),full)\n"
1210 "$(intermediate_path_noext)_p.o.d: $(intermediate_path_noext)_p.c | $(intermediate_dir)\n"
1211 "\t$(ECHO_DEPENDS)\n"
1212 "\t${gcc} -MF $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -M -MP -MT $@ $<\n"
1213 "-include $(intermediate_path_noext)_p.o.d\n"
1215 "$(intermediate_path_noext)_p.o: $(intermediate_path_noext)_p.c $(intermediate_path_noext)_p.h$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_noext)_p.o.d) $(dependencies) | $(intermediate_dir)\n"
1217 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1218 "$(intermediate_path_noext)_p.h",
1219 "$(intermediate_path_noext)_p.c",
1220 "$(intermediate_path_noext)_p.o",
1221 "$(intermediate_path_noext)_p.o.d",
1222 "$(intermediate_dir)$(SEP)", NULL
);
1223 Rule
widlDlldataRule ( "$(source): $(dependencies) ${$(module_name)_precondition} $(WIDL_TARGET) | $(intermediate_dir)\n"
1225 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) --dlldata-only --dlldata=$(source) $(bare_dependencies)\n"
1226 "ifeq ($(ROS_BUILDDEPS),full)\n"
1227 "$(intermediate_path_noext).o.d: $(source) | $(intermediate_dir)\n"
1228 "\t$(ECHO_DEPENDS)\n"
1229 "\t${gcc} -MF $@ $($(module_name)_CFLAGS)$(compiler_flags) -M -MP -MT $@ $<\n"
1230 "-include $(intermediate_path_noext).o.d\n"
1232 "$(intermediate_path_noext).o: $(source)$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_path_noext).o.d) $(dependencies) | $(intermediate_dir)\n"
1234 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1235 "$(intermediate_path_noext).o",
1236 "$(intermediate_path_noext).o.d", NULL
);
1237 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1238 "$(intermediate_dir)$(SEP)$(module_name).tlb: $(source) $(dependencies) $(WIDL_TARGET) | $(intermediate_dir)\n"
1240 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(intermediate_path_noext).tlb $(source)\n",
1241 "$(intermediate_dir)$(SEP)", NULL
);
1242 Rule
gccRule ( "$(eval $(call RBUILD_GCC_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1243 "$(intermediate_path_unique).o",
1244 "$(intermediate_path_unique).o.d", NULL
);
1245 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1246 "$(intermediate_path_unique).o: $(source) $(dependencies) | $(intermediate_dir)\n"
1247 "\t$(ECHO_HOSTCC)\n"
1248 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1249 "$(intermediate_path_unique).o", NULL
);
1250 Rule
gppRule ( "$(eval $(call RBUILD_GPP_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1251 "$(intermediate_path_unique).o",
1252 "$(intermediate_path_unique).o.d", NULL
);
1253 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1254 "$(intermediate_path_unique).o: $(source) $(dependencies) | $(intermediate_dir)\n"
1255 "\t$(ECHO_HOSTCC)\n"
1256 "\t${host_gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1257 "$(intermediate_path_unique).o", NULL
);
1258 Rule
pchRule ( "$(source): ${$(module_name)_precondition}\n"
1259 "ifeq ($(ROS_BUILDDEPS),full)\n"
1260 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch.d: $(source) | $(intermediate_dir)\n"
1261 "\t$(ECHO_DEPENDS)\n"
1262 "\t$(pch_cc) -MF $@ $(pch_ccflags)$(compiler_flags) -x $(pch_language) -M -MP -MT $@ $<\n"
1263 "-include $(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch.d\n"
1265 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch: $(source)$(if $(subst _full,,_$(ROS_BUILDDEPS)),, $(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch.d) $(dependencies) | $(intermediate_dir)$(SEP).gch_$(module_name)\n"
1267 "\t$(pch_cc) -o $@ $(pch_ccflags)$(compiler_flags) -x $(pch_language) -c $<\n",
1268 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch",
1269 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch.d", NULL
);
1270 Rule
emptyRule ( "", NULL
);
1273 MingwModuleHandler::GenerateGccCommand (
1274 const FileLocation
* sourceFile
,
1276 const string
& extraDependencies
)
1278 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1279 string dependencies
= extraDependencies
;
1282 string extension
= GetExtension ( *sourceFile
);
1283 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1284 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1286 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1290 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1294 /* WIDL generated headers may be used */
1295 vector
<FileLocation
> rpcDependencies
;
1296 GetRpcHeaderDependencies ( rpcDependencies
);
1297 if ( rpcDependencies
.size () > 0 )
1298 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1300 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1304 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1306 const Property
* property
= module
.project
.LookupProperty(name
);
1309 return property
->value
;
1311 return string ( "" );
1314 /* caller needs to delete the returned object */
1316 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1318 string newname
= GetBasename ( base
->name
) + "_s.h";
1319 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1322 /* caller needs to delete the returned object */
1324 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1326 string newname
= GetBasename ( base
->name
) + "_c.h";
1327 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1330 /* caller needs to delete the returned object */
1332 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1334 string newname
= GetBasename ( base
->name
) + "_p.h";
1335 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1338 /* caller needs to delete the returned object */
1340 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1342 string newname
= GetBasename ( base
->name
) + ".h";
1343 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1346 /* caller needs to delete the returned object */
1348 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1350 string newname
= GetBasename ( base
->name
) + ".h";
1351 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1355 MingwModuleHandler::GenerateCommands (
1356 const CompilationUnit
& compilationUnit
,
1357 const string
& extraDependencies
)
1359 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1360 string extension
= GetExtension ( sourceFile
);
1361 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1370 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1371 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1372 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1373 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1374 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1375 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1376 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1377 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1378 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1379 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1380 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1381 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1382 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1383 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1384 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1385 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1386 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1387 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1388 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1391 Rule
*customRule
= NULL
;
1393 fprintf ( fMakefile
, "# COMMANDS\n" );
1395 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1397 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1399 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1401 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1403 customRule
= rules
[i
].rule
;
1407 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1409 GenerateGccCommand ( &sourceFile
,
1411 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1413 else if ( customRule
)
1414 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1417 throw InvalidOperationException ( __FILE__
,
1419 "Unsupported filename extension '%s' in file '%s'",
1421 backend
->GetFullName ( sourceFile
).c_str () );
1426 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1428 fprintf ( fMakefile
, "# BUILD MAP CODE\n" );
1430 fprintf ( fMakefile
,
1431 "ifeq ($(ROS_BUILDMAP),full)\n" );
1433 FileLocation
mapFilename ( OutputDirectory
,
1434 module
.output
->relative_path
,
1435 GetBasename ( module
.output
->name
) + ".map" );
1436 CLEAN_FILE ( mapFilename
);
1438 fprintf ( fMakefile
,
1439 "\t$(ECHO_OBJDUMP)\n" );
1440 fprintf ( fMakefile
,
1441 "\t$(Q)${objdump} -d -S %s > %s\n",
1442 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1443 backend
->GetFullName ( mapFilename
).c_str () );
1445 fprintf ( fMakefile
,
1447 fprintf ( fMakefile
,
1448 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1450 fprintf ( fMakefile
,
1452 fprintf ( fMakefile
,
1453 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1454 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1455 backend
->GetFullName ( mapFilename
).c_str () );
1457 fprintf ( fMakefile
,
1460 fprintf ( fMakefile
,
1465 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1467 fprintf ( fMakefile
, "# BUILD NO STRIP CODE\n" );
1469 fprintf ( fMakefile
,
1470 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1472 FileLocation
nostripFilename ( OutputDirectory
,
1473 module
.output
->relative_path
,
1474 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1475 CLEAN_FILE ( nostripFilename
);
1477 OutputCopyCommand ( *module
.output
, nostripFilename
);
1479 fprintf ( fMakefile
,
1484 MergeStringVector ( const Backend
* backend
,
1485 const vector
<FileLocation
>& input
,
1486 vector
<string
>& output
)
1490 int wrap_count
= -1;
1491 for ( size_t i
= 0; i
< input
.size (); i
++ )
1493 if ( wrap_count
++ == wrap_at
)
1495 output
.push_back ( s
);
1499 else if ( s
.size () > 0)
1501 s
+= backend
->GetFullName ( input
[i
] );
1503 if ( s
.length () > 0 )
1504 output
.push_back ( s
);
1508 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1509 vector
<FileLocation
>& objectFiles
) const
1511 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1513 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1514 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1515 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1516 objectFiles
.push_back ( *object_file
);
1522 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1524 if ( backend
->configuration
.CleanAsYouGo
)
1526 vector
<FileLocation
> objectFiles
;
1527 GetObjectsVector ( module
.non_if_data
,
1529 vector
<string
> lines
;
1530 MergeStringVector ( backend
,
1533 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1535 fprintf ( fMakefile
,
1536 "\t-@${rm} %s 2>$(NUL)\n",
1537 lines
[i
].c_str () );
1543 MingwModuleHandler::GenerateRunRsymCode () const
1545 fprintf ( fMakefile
, "# RUN RSYM CODE\n" );
1546 fprintf ( fMakefile
,
1547 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1548 fprintf ( fMakefile
,
1549 "\t$(ECHO_RSYM)\n" );
1550 fprintf ( fMakefile
,
1551 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1552 fprintf ( fMakefile
,
1557 MingwModuleHandler::GenerateRunStripCode () const
1559 fprintf ( fMakefile
, "# RUN STRIP CODE\n" );
1560 fprintf ( fMakefile
,
1561 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1562 fprintf ( fMakefile
,
1563 "\t$(ECHO_STRIP)\n" );
1564 fprintf ( fMakefile
,
1565 "\t${strip} -s -x -X $@\n\n" );
1566 fprintf ( fMakefile
,
1571 MingwModuleHandler::GenerateLinkerCommand (
1572 const string
& dependencies
,
1573 const string
& linkerParameters
,
1574 const string
& pefixupParameters
)
1576 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1577 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1578 string linker
= "${ld}";
1579 string objectsMacro
= GetObjectsMacro ( module
);
1580 string libsMacro
= GetLibsMacro ();
1582 fprintf ( fMakefile
, "# LINKER COMMAND\n" );
1584 string
target_macro ( GetTargetMacro ( module
) );
1585 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1587 string linkerScriptArgument
;
1588 if ( module
.linkerScript
!= NULL
)
1589 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1591 linkerScriptArgument
= "";
1593 /* check if we need to add default C++ libraries, ie if we have
1594 * a C++ user-mode module without the -nostdlib linker flag
1596 bool link_defaultlibs
= module
.cplusplus
&&
1597 linkerParameters
.find ("-nostdlib") == string::npos
&&
1598 !(module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
);
1600 if ( !module
.HasImportLibrary() )
1602 fprintf ( fMakefile
,
1603 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1604 target_macro
.c_str (),
1605 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1606 dependencies
.c_str (),
1607 target_folder
.c_str () );
1608 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1610 fprintf ( fMakefile
,
1611 "\t%s %s%s %s %s %s %s -o %s\n",
1613 linkerParameters
.c_str (),
1614 linkerScriptArgument
.c_str (),
1615 objectsMacro
.c_str (),
1616 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1618 GetLinkerMacro ().c_str (),
1619 target_macro
.c_str () );
1623 FileLocation
temp_exp ( IntermediateDirectory
,
1624 module
.output
->relative_path
,
1625 module
.name
+ ".exp" );
1626 CLEAN_FILE ( temp_exp
);
1628 fprintf ( fMakefile
,
1630 backend
->GetFullName ( temp_exp
).c_str (),
1631 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1632 backend
->GetFullPath ( temp_exp
).c_str () );
1633 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1635 fprintf ( fMakefile
,
1636 "\t${dlltool} --dllname %s --def %s --output-exp $@%s%s\n",
1637 module
.GetDllName ().c_str (),
1638 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1639 module
.mangledSymbols
? "" : " --kill-at",
1640 module
.underscoreSymbols
? " --add-underscore" : "" );
1642 fprintf ( fMakefile
,
1643 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1644 target_macro
.c_str (),
1645 backend
->GetFullName ( temp_exp
).c_str (),
1646 dependencies
.c_str (),
1647 target_folder
.c_str () );
1648 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1650 fprintf ( fMakefile
,
1651 "\t%s %s%s %s %s %s %s %s -o %s\n",
1654 linkerParameters
.c_str (),
1655 linkerScriptArgument
.c_str (),
1656 backend
->GetFullName ( temp_exp
).c_str (),
1657 objectsMacro
.c_str (),
1658 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1660 GetLinkerMacro ().c_str (),
1661 target_macro
.c_str () );
1663 fprintf ( fMakefile
,
1664 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1665 target_macro
.c_str (),
1666 pefixupParameters
.c_str() );
1669 GenerateBuildMapCode ();
1670 GenerateBuildNonSymbolStrippedCode ();
1671 GenerateRunRsymCode ();
1672 GenerateRunStripCode ();
1673 GenerateCleanObjectsAsYouGoCode ();
1675 if ( definitionFilename
)
1676 delete definitionFilename
;
1681 MingwModuleHandler::GeneratePhonyTarget() const
1683 string
targetMacro ( GetTargetMacro ( module
) );
1684 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1686 fprintf ( fMakefile
, "# PHONY TARGET\n" );
1687 fprintf ( fMakefile
,
1689 targetMacro
.c_str ());
1690 fprintf ( fMakefile
, "%s: | %s\n",
1691 targetMacro
.c_str (),
1692 backend
->GetFullPath ( *target_file
).c_str () );
1698 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1701 string moduleDependencies
;
1703 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1705 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1706 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1708 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1709 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1710 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1711 if ( GetExtension ( *objectFilename
) == ".h" )
1712 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1713 else if ( GetExtension ( *objectFilename
) == ".rc" )
1714 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1715 delete objectFilename
;
1718 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1720 GenerateCommands ( *compilationUnits
[i
],
1721 moduleDependencies
);
1722 fprintf ( fMakefile
,
1726 vector
<CompilationUnit
*> sourceCompilationUnits
;
1727 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1728 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1730 GenerateCommands ( *sourceCompilationUnits
[i
],
1731 moduleDependencies
);
1733 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1735 SpecFileType spec
= IsSpecDefinitionFile ();
1742 defRule
= &winebuildPRule
;
1744 defRule
= &winebuildRule
;
1746 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
1749 if ( module
.type
== RpcProxy
)
1751 widlDlldataRule
.Execute ( fMakefile
,
1754 GetDlldataFilename(),
1756 ssprintf ( "$(%s_SOURCES)", module
.name
.c_str ()) );
1761 MingwModuleHandler::GenerateObjectFileTargets ()
1763 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1765 if ( module
.pch
&& use_pch
)
1768 std::map
<string
, string
> vars
;
1770 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1771 vars
["pch_cc"] = "${host_gcc}";
1773 vars
["pch_cc"] = "${gcc}";
1775 if ( module
.cplusplus
)
1777 vars
["pch_language"] = "c++-header";
1778 vars
["pch_ccflags"] = cxxflagsMacro
.c_str();
1782 vars
["pch_language"] = "c-header";
1783 vars
["pch_ccflags"] = cflagsMacro
.c_str();
1786 /* WIDL generated headers may be used */
1787 string dependencies
;
1788 vector
<FileLocation
> rpcDependencies
;
1789 GetRpcHeaderDependencies ( rpcDependencies
);
1790 if ( rpcDependencies
.size () > 0 )
1791 dependencies
= " " + v2s ( backend
, rpcDependencies
, 5 );
1793 pchRule
.Execute ( fMakefile
,
1799 GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, module
.cplusplus
? CompilerTypeCPP
: CompilerTypeCC
).c_str(),
1801 fprintf ( fMakefile
, "\n" );
1804 GenerateObjectFileTargets ( module
.non_if_data
);
1805 fprintf ( fMakefile
, "\n" );
1808 /* caller needs to delete the returned object */
1810 MingwModuleHandler::GenerateArchiveTarget ()
1812 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1813 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1815 fprintf ( fMakefile
, "# ARCHIVE TARGET\n" );
1817 if ( IsStaticLibrary ( module
) && definitionFilename
)
1819 arRule1
.Execute ( fMakefile
,
1824 backend
->GetFullName ( *definitionFilename
).c_str () );
1826 fprintf ( fMakefile
,
1827 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1828 module
.GetDllName ().c_str (),
1829 backend
->GetFullName ( *definitionFilename
).c_str (),
1830 module
.mangledSymbols
? "" : " --kill-at",
1831 module
.underscoreSymbols
? " --add-underscore" : "" );
1834 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1836 if ( definitionFilename
)
1837 delete definitionFilename
;
1839 if(module
.type
== HostStaticLibrary
)
1840 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1842 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1844 GenerateCleanObjectsAsYouGoCode ();
1846 fprintf ( fMakefile
, "\n" );
1848 return archiveFilename
;
1852 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1854 return ssprintf ( "$(%s_OBJS)",
1855 module
.name
.c_str () );
1859 MingwModuleHandler::GetLinkingDependenciesMacro () const
1861 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1865 MingwModuleHandler::GetLibsMacro () const
1867 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1871 MingwModuleHandler::GetLinkerMacro () const
1873 return ssprintf ( "$(%s_LFLAGS)",
1874 module
.name
.c_str () );
1878 MingwModuleHandler::GetDebugFormat () const
1880 if (Environment::GetArch() == "amd64")
1888 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1890 if ( ReferenceObjects ( module
) )
1891 return GetObjectsMacro ( module
);
1894 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1895 string target
= backend
->GetFullName ( *target_file
).c_str ();
1902 MingwModuleHandler::GenerateSourceMacro ()
1904 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1906 GenerateSourceMacros ( module
.non_if_data
);
1908 // future references to the macro will be to get its values
1909 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1913 MingwModuleHandler::GenerateObjectMacro ()
1915 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1917 GenerateObjectMacros ( module
.non_if_data
);
1919 // future references to the macro will be to get its values
1920 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1924 MingwModuleHandler::GenerateTargetMacro ()
1926 fprintf ( fMakefile
, "# TARGET MACRO\n" );
1927 fprintf ( fMakefile
,
1929 GetTargetMacro ( module
, false ).c_str (),
1930 GetModuleTargets ( module
).c_str () );
1934 MingwModuleHandler::GetRpcHeaderDependencies (
1935 vector
<FileLocation
>& dependencies
) const
1937 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1939 Library
& library
= *module
.non_if_data
.libraries
[i
];
1940 if ( library
.importedModule
->type
== RpcServer
||
1941 library
.importedModule
->type
== RpcClient
||
1942 library
.importedModule
->type
== RpcProxy
||
1943 library
.importedModule
->type
== IdlHeader
)
1945 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1947 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1948 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1949 string extension
= GetExtension ( sourceFile
);
1950 if ( extension
== ".idl" || extension
== ".IDL" )
1952 string basename
= GetBasename ( sourceFile
.name
);
1953 if ( library
.importedModule
->type
== RpcServer
)
1955 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1956 dependencies
.push_back ( *header
);
1959 if ( library
.importedModule
->type
== RpcClient
)
1961 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1962 dependencies
.push_back ( *header
);
1965 if ( library
.importedModule
->type
== RpcProxy
)
1967 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1968 dependencies
.push_back ( *header
);
1971 if ( library
.importedModule
->type
== IdlHeader
)
1973 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1974 dependencies
.push_back ( *header
);
1984 MingwModuleHandler::GenerateOtherMacros ()
1986 set
<const Define
*> used_defs
;
1988 fprintf ( fMakefile
, "# OTHER MACROS\n" );
1990 commonflagsMacro
= ssprintf ("%s_COMMONFLAGS", module
.name
.c_str ());
1991 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1992 cxxflagsMacro
= ssprintf ("%s_CXXFLAGS", module
.name
.c_str ());
1993 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1994 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1995 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1996 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1997 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1998 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
2003 &module
.linkerFlags
,
2006 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2008 GenerateMacros("+=", module
.project
.host_non_if_data
, NULL
, used_defs
);
2014 module
.project
.non_if_data
,
2019 if ( IsSpecDefinitionFile() )
2021 vector
<FileLocation
> s
;
2022 GetSpecImplibDependencies ( s
, module
.importLibrary
->source
);
2027 linkDepsMacro
.c_str() );
2028 for ( size_t i
= 0; i
< s
.size(); i
++ )
2029 fprintf ( fMakefile
,
2031 backend
->GetFullName ( s
[i
] ).c_str () );
2032 fprintf ( fMakefile
, "\n" );
2035 string globalCflags
= " ";
2036 globalCflags
+= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
2037 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
2039 if ( module
.dynamicCRT
)
2040 globalCflags
+= " -D_DLL -D__USE_CRTIMP";
2043 globalCflags
+= " -Wall -Wpointer-arith";
2044 globalCflags
+= " -g" + MingwModuleHandler::GetDebugFormat ();
2045 if ( backend
->usePipe
)
2046 globalCflags
+= " -pipe";
2047 if ( !module
.allowWarnings
)
2048 globalCflags
+= " -Werror";
2049 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2051 if ( module
.cplusplus
)
2052 globalCflags
+= " $(HOST_CPPFLAGS)";
2054 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
2058 if ( module
.cplusplus
)
2060 globalCflags
+= " $(TARGET_CPPFLAGS)";
2063 globalCflags
+= " -nostdinc";
2066 // Always force disabling of sibling calls optimisation for GCC
2067 // (TODO: Move to version-specific once this bug is fixed in GCC)
2068 globalCflags
+= " -fno-optimize-sibling-calls";
2070 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
2075 cflagsMacro
.c_str (),
2076 (" $(PROJECT_CFLAGS)" + globalCflags
).c_str () );
2081 cxxflagsMacro
.c_str (),
2082 (" $(PROJECT_CXXFLAGS)" + globalCflags
).c_str () );
2086 "%s += $(PROJECT_RCFLAGS)\n",
2087 windresflagsMacro
.c_str () );
2091 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
2092 widlflagsMacro
.c_str (),
2093 module
.output
->relative_path
.c_str () );
2097 "%s_LFLAGS := $(PROJECT_LFLAGS) $(%s_LFLAGS)\n",
2098 module
.name
.c_str (),
2099 module
.name
.c_str () );
2106 cflagsMacro
.c_str (),
2107 globalCflags
.c_str () );
2112 cxxflagsMacro
.c_str (),
2113 globalCflags
.c_str () );
2117 "%s_LFLAGS += $(HOST_LFLAGS)\n",
2118 module
.name
.c_str () );
2124 linkDepsMacro
.c_str (),
2125 libsMacro
.c_str () );
2127 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
2128 if ( strlen( cflags
) > 0 )
2130 fprintf ( fMakefile
,
2132 cflagsMacro
.c_str (),
2134 fprintf ( fMakefile
,
2136 cxxflagsMacro
.c_str (),
2140 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
2141 if ( strlen( nasmflags
) > 0 )
2143 fprintf ( fMakefile
,
2145 nasmflagsMacro
.c_str (),
2149 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
2150 if ( strlen( linkerflags
) > 0 )
2152 fprintf ( fMakefile
,
2154 linkerflagsMacro
.c_str (),
2158 fprintf ( fMakefile
, "\n\n" );
2160 // future references to the macros will be to get their values
2161 commonflagsMacro
= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
2162 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2163 cxxflagsMacro
= ssprintf ("$(%s)", cxxflagsMacro
.c_str ());
2164 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2165 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2169 MingwModuleHandler::GenerateRules ()
2173 fprintf ( fMakefile
, "# RULES\n" );
2174 string targetMacro
= GetTargetMacro ( module
);
2175 //CLEAN_FILE ( targetMacro );
2176 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2178 // generate phony target for module name
2179 fprintf ( fMakefile
, ".PHONY: %s\n",
2180 module
.name
.c_str () );
2181 string dependencies
= GetTargetMacro ( module
);
2182 if ( module
.type
== Test
)
2183 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2184 fprintf ( fMakefile
, "%s: %s\n\n",
2185 module
.name
.c_str (),
2186 dependencies
.c_str () );
2187 if ( module
.type
== Test
)
2189 fprintf ( fMakefile
,
2191 targetMacro
.c_str ());
2194 if ( !ReferenceObjects ( module
) )
2196 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2201 spec
= IsSpecDefinitionFile();
2208 defRule
= &winebuildPDefRule
;
2210 defRule
= &winebuildDefRule
;
2212 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
2215 GenerateObjectFileTargets ();
2219 MingwModuleHandler::GetInvocationDependencies (
2220 const Module
& module
,
2221 string_list
& dependencies
)
2223 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2225 Invoke
& invoke
= *module
.invocations
[i
];
2226 if ( invoke
.invokeModule
== &module
)
2227 /* Protect against circular dependencies */
2229 invoke
.GetTargets ( dependencies
);
2234 MingwModuleHandler::GenerateInvocations () const
2236 if ( module
.invocations
.size () == 0 )
2239 fprintf ( fMakefile
, "# INVOCATIONS\n" );
2241 size_t iend
= module
.invocations
.size ();
2242 for ( size_t i
= 0; i
< iend
; i
++ )
2244 const Invoke
& invoke
= *module
.invocations
[i
];
2246 if ( invoke
.invokeModule
->type
!= BuildTool
)
2248 throw XMLInvalidBuildFileException (
2249 module
.node
.location
,
2250 "Only modules of type buildtool can be invoked." );
2253 string invokeTarget
= module
.GetInvocationTarget ( i
);
2254 string_list invoke_targets
;
2255 assert ( invoke_targets
.size() );
2256 invoke
.GetTargets ( invoke_targets
);
2257 fprintf ( fMakefile
,
2259 invokeTarget
.c_str () );
2260 fprintf ( fMakefile
,
2262 invokeTarget
.c_str () );
2263 size_t j
, jend
= invoke_targets
.size();
2264 for ( j
= 0; j
< jend
; j
++ )
2266 fprintf ( fMakefile
,
2268 invoke_targets
[i
].c_str () );
2270 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2271 for ( j
= 1; j
< jend
; j
++ )
2272 fprintf ( fMakefile
,
2274 invoke_targets
[i
].c_str () );
2275 fprintf ( fMakefile
,
2277 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2278 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2279 fprintf ( fMakefile
,
2281 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2282 invoke
.GetParameters ().c_str () );
2287 MingwModuleHandler::GetPreconditionDependenciesName () const
2289 return module
.name
+ "_precondition";
2293 MingwModuleHandler::GetDefaultDependencies (
2294 string_list
& dependencies
) const
2296 /* Avoid circular dependency */
2297 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2300 if (module
.name
!= "psdk" &&
2301 module
.name
!= "dxsdk")
2303 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2304 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2307 if (module
.name
!= "errcodes" &&
2308 module
.name
!= "bugcodes" &&
2309 module
.name
!= "ntstatus")
2311 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2312 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2313 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2316 ///* Check if any dependent library relies on the generated headers */
2317 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2319 // const Module& m = *module.project.modules[i];
2320 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2322 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2323 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2324 // string extension = GetExtension ( sourceFile );
2325 // if (extension == ".mc" || extension == ".MC" )
2327 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2328 // dependencies.push_back ( dependency );
2335 MingwModuleHandler::GeneratePreconditionDependencies ()
2337 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
2338 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2339 string_list dependencies
;
2340 GetDefaultDependencies ( dependencies
);
2341 GetModuleDependencies ( dependencies
);
2343 GetInvocationDependencies ( module
, dependencies
);
2345 if ( dependencies
.size() )
2347 fprintf ( fMakefile
,
2349 preconditionDependenciesName
.c_str () );
2350 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2351 fprintf ( fMakefile
,
2353 dependencies
[i
].c_str () );
2354 fprintf ( fMakefile
, "\n\n" );
2357 fprintf ( fMakefile
, "\n" );
2361 MingwModuleHandler::IsSpecDefinitionFile () const
2363 if(!module
.importLibrary
)
2366 std::string ext
= GetExtension ( *module
.importLibrary
->source
);
2368 if ( ext
== ".spec" )
2371 if ( ext
== ".pspec" )
2377 /* caller needs to delete the returned object */
2379 MingwModuleHandler::GetDefinitionFilename () const
2381 if ( module
.importLibrary
== NULL
)
2384 if ( IsSpecDefinitionFile () )
2386 return new FileLocation ( IntermediateDirectory
,
2387 module
.importLibrary
->source
->relative_path
,
2388 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2392 return new FileLocation ( SourceDirectory
,
2393 module
.importLibrary
->source
->relative_path
,
2394 module
.importLibrary
->source
->name
);
2399 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2401 if ( module
.importLibrary
!= NULL
)
2403 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2404 const FileLocation
*defFilename
= GetDefinitionFilename ();
2405 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2407 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE\n" );
2409 fprintf ( fMakefile
, "%s:",
2410 backend
->GetFullName ( *library_target
).c_str () );
2414 fprintf ( fMakefile
, " %s",
2415 backend
->GetFullName ( *defFilename
).c_str () );
2418 fprintf ( fMakefile
, " | %s\n",
2419 backend
->GetFullPath ( *library_target
).c_str () );
2421 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2423 fprintf ( fMakefile
,
2424 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2425 module
.GetDllName ().c_str (),
2426 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2428 backend
->GetFullName ( *library_target
).c_str (),
2429 module
.mangledSymbols
? "" : " --kill-at",
2430 module
.underscoreSymbols
? " --add-underscore" : "" );
2434 delete library_target
;
2439 MingwModuleHandler::GetSpecObjectDependencies (
2440 vector
<FileLocation
>& dependencies
,
2441 const FileLocation
*file
) const
2443 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2444 file
->relative_path
,
2445 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2449 MingwModuleHandler::GetSpecImplibDependencies (
2450 vector
<FileLocation
>& dependencies
,
2451 const FileLocation
*file
) const
2453 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2454 file
->relative_path
,
2455 GetBasename ( file
->name
) + "_" + module
.name
+ ".auto.def" ) );
2459 MingwModuleHandler::GetMcObjectDependencies (
2460 vector
<FileLocation
>& dependencies
,
2461 const FileLocation
*file
) const
2463 string basename
= GetBasename ( file
->name
);
2465 FileLocation
defDependency ( IntermediateDirectory
,
2468 dependencies
.push_back ( defDependency
);
2470 FileLocation
stubsDependency ( IntermediateDirectory
,
2471 file
->relative_path
,
2473 dependencies
.push_back ( stubsDependency
);
2477 MingwModuleHandler::GetWidlObjectDependencies (
2478 vector
<FileLocation
>& dependencies
,
2479 const FileLocation
*file
) const
2481 string basename
= GetBasename ( file
->name
);
2482 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2484 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2485 file
->relative_path
,
2486 basename
+ "_s.c" );
2487 dependencies
.push_back ( serverSourceDependency
);
2488 dependencies
.push_back ( *generatedHeaderFilename
);
2490 delete generatedHeaderFilename
;
2494 MingwModuleHandler::GetDefinitionDependencies (
2495 vector
<FileLocation
>& dependencies
) const
2497 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2498 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2500 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2501 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2502 string extension
= GetExtension ( sourceFile
);
2504 if (extension
== ".spec" || extension
== ".pspec")
2505 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2507 if (extension
== ".idl")
2509 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2510 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2515 enum DebugSupportType
2522 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2528 case DebugKernelMode
:
2529 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2533 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2540 module
.non_if_data
.libraries
.push_back(pLibrary
);
2544 MingwAddCRTLibrary( Module
&module
)
2546 const char * crtAttr
= module
.CRT
.c_str ();
2547 const char * crtLib
= NULL
;
2549 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2551 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2553 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2554 crtLib
= "libcntpr";
2555 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2560 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2562 if ( pLibrary
->importedModule
== NULL
)
2564 throw XMLInvalidBuildFileException (
2565 module
.node
.location
,
2566 "module '%s' trying to import non-existant C runtime module '%s'",
2567 module
.name
.c_str(),
2571 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2575 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2576 : MingwModuleHandler ( module_
)
2581 MingwBuildToolModuleHandler::Process ()
2583 GenerateBuildToolModuleTarget ();
2587 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2589 string
targetMacro ( GetTargetMacro (module
) );
2590 string objectsMacro
= GetObjectsMacro ( module
);
2591 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2592 string libsMacro
= GetLibsMacro ();
2596 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2599 if ( module
.cplusplus
)
2600 linker
= "${host_gpp}";
2602 linker
= "${host_gcc}";
2604 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2605 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2606 targetMacro
.c_str (),
2607 objectsMacro
.c_str (),
2608 linkDepsMacro
.c_str (),
2609 backend
->GetFullPath ( *target_file
).c_str () );
2610 fprintf ( fMakefile
, "\t$(ECHO_HOSTLD)\n" );
2611 fprintf ( fMakefile
,
2612 "\t%s %s -o $@ %s %s\n\n",
2614 GetLinkerMacro ().c_str (),
2615 objectsMacro
.c_str (),
2616 libsMacro
.c_str () );
2622 MingwKernelModuleHandler::MingwKernelModuleHandler (
2623 const Module
& module_
)
2625 : MingwModuleHandler ( module_
)
2630 MingwKernelModuleHandler::Process ()
2632 GenerateKernelModuleTarget ();
2636 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2638 string
targetMacro ( GetTargetMacro ( module
) );
2639 string workingDirectory
= GetWorkingDirectory ( );
2640 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2642 GenerateImportLibraryTargetIfNeeded ();
2644 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2648 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2650 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2651 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2652 module
.baseaddress
.c_str () );
2654 GenerateLinkerCommand ( dependencies
,
2655 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2660 GeneratePhonyTarget();
2665 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2666 const Module
& module_
)
2668 : MingwModuleHandler ( module_
)
2674 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2676 MingwAddCRTLibrary ( module
);
2677 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2681 MingwKernelModeDLLModuleHandler::Process ()
2683 GenerateKernelModeDLLModuleTarget ();
2687 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2689 string
targetMacro ( GetTargetMacro ( module
) );
2690 string workingDirectory
= GetWorkingDirectory ();
2691 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2693 GenerateImportLibraryTargetIfNeeded ();
2695 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2699 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2701 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2702 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2703 module
.baseaddress
.c_str () );
2704 GenerateLinkerCommand ( dependencies
,
2710 GeneratePhonyTarget();
2715 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2716 const Module
& module_
)
2718 : MingwModuleHandler ( module_
)
2723 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2725 MingwAddCRTLibrary ( module
);
2726 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2730 MingwNativeDLLModuleHandler::Process ()
2732 GenerateNativeDLLModuleTarget ();
2736 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2738 string
targetMacro ( GetTargetMacro (module
) );
2739 string workingDirectory
= GetWorkingDirectory ( );
2740 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2742 GenerateImportLibraryTargetIfNeeded ();
2744 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2748 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2750 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2751 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2752 module
.baseaddress
.c_str () );
2753 GenerateLinkerCommand ( dependencies
,
2759 GeneratePhonyTarget();
2764 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2765 const Module
& module_
)
2767 : MingwModuleHandler ( module_
)
2772 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2774 MingwAddCRTLibrary ( module
);
2775 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2779 MingwNativeCUIModuleHandler::Process ()
2781 GenerateNativeCUIModuleTarget ();
2785 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2787 string
targetMacro ( GetTargetMacro (module
) );
2788 string workingDirectory
= GetWorkingDirectory ( );
2789 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2791 GenerateImportLibraryTargetIfNeeded ();
2793 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2797 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2799 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2800 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2801 module
.baseaddress
.c_str () );
2802 GenerateLinkerCommand ( dependencies
,
2808 GeneratePhonyTarget();
2813 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2814 const Module
& module_
)
2816 : MingwModuleHandler ( module_
)
2820 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2821 const Module
& module_
)
2823 : MingwModuleHandler ( module_
)
2828 MingwAddImplicitLibraries( Module
&module
)
2832 if ( module
.type
!= Win32DLL
2833 && module
.type
!= Win32OCX
2834 && module
.type
!= Win32CUI
2835 && module
.type
!= Win32GUI
2836 && module
.type
!= Win32SCR
)
2841 if ( module
.isDefaultEntryPoint
)
2843 if ( module
.IsDLL () )
2845 //pLibrary = new Library ( module, "__mingw_dllmain" );
2846 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2850 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2851 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2855 pLibrary
= new Library ( module
, "mingw_common" );
2856 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2858 MingwAddCRTLibrary ( module
);
2859 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2863 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2865 MingwAddImplicitLibraries ( module
);
2869 MingwWin32DLLModuleHandler::Process ()
2871 GenerateWin32DLLModuleTarget ();
2875 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2877 string
targetMacro ( GetTargetMacro (module
) );
2878 string workingDirectory
= GetWorkingDirectory ( );
2879 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2881 GenerateImportLibraryTargetIfNeeded ();
2883 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2887 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2889 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2890 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2891 module
.baseaddress
.c_str () );
2892 GenerateLinkerCommand ( dependencies
,
2898 GeneratePhonyTarget();
2904 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2906 MingwAddImplicitLibraries ( module
);
2910 MingwWin32OCXModuleHandler::Process ()
2912 GenerateWin32OCXModuleTarget ();
2916 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2918 string
targetMacro ( GetTargetMacro (module
) );
2919 string workingDirectory
= GetWorkingDirectory ( );
2920 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2922 GenerateImportLibraryTargetIfNeeded ();
2924 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2928 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2930 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2931 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2932 module
.baseaddress
.c_str () );
2933 GenerateLinkerCommand ( dependencies
,
2939 GeneratePhonyTarget();
2944 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2945 const Module
& module_
)
2947 : MingwModuleHandler ( module_
)
2952 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2954 MingwAddImplicitLibraries ( module
);
2958 MingwWin32CUIModuleHandler::Process ()
2960 GenerateWin32CUIModuleTarget ();
2964 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2966 string
targetMacro ( GetTargetMacro (module
) );
2967 string workingDirectory
= GetWorkingDirectory ( );
2968 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2970 GenerateImportLibraryTargetIfNeeded ();
2972 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2976 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2978 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2979 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2980 module
.baseaddress
.c_str () );
2981 GenerateLinkerCommand ( dependencies
,
2987 GeneratePhonyTarget();
2992 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2993 const Module
& module_
)
2995 : MingwModuleHandler ( module_
)
3000 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3002 MingwAddImplicitLibraries ( module
);
3006 MingwWin32GUIModuleHandler::Process ()
3008 GenerateWin32GUIModuleTarget ();
3012 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
3014 string
targetMacro ( GetTargetMacro (module
) );
3015 string workingDirectory
= GetWorkingDirectory ( );
3016 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3018 GenerateImportLibraryTargetIfNeeded ();
3020 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3024 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3026 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3027 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3028 module
.baseaddress
.c_str () );
3029 GenerateLinkerCommand ( dependencies
,
3035 GeneratePhonyTarget();
3040 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
3041 const Module
& module_
)
3043 : MingwModuleHandler ( module_
)
3048 MingwBootLoaderModuleHandler::Process ()
3050 GenerateBootLoaderModuleTarget ();
3054 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
3056 string
targetName ( module
.output
->name
);
3057 string
targetMacro ( GetTargetMacro (module
) );
3058 string workingDirectory
= GetWorkingDirectory ();
3059 FileLocation
junk_tmp ( TemporaryDirectory
,
3061 module
.name
+ ".junk.tmp" );
3062 CLEAN_FILE ( junk_tmp
);
3063 string objectsMacro
= GetObjectsMacro ( module
);
3064 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3068 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
3070 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3071 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3072 targetMacro
.c_str (),
3073 objectsMacro
.c_str (),
3074 linkDepsMacro
.c_str (),
3075 backend
->GetFullPath ( *target_file
).c_str () );
3077 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
3079 if (Environment::GetArch() == "arm")
3081 fprintf ( fMakefile
,
3082 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
3083 backend
->GetFullName ( junk_tmp
).c_str (),
3084 objectsMacro
.c_str (),
3085 linkDepsMacro
.c_str (),
3086 GetLinkerMacro ().c_str ());
3090 fprintf ( fMakefile
,
3091 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
3092 backend
->GetFullName ( junk_tmp
).c_str (),
3093 objectsMacro
.c_str (),
3094 linkDepsMacro
.c_str (),
3095 GetLinkerMacro ().c_str ());
3097 fprintf ( fMakefile
,
3098 "\t${objcopy} -O binary %s $@\n",
3099 backend
->GetFullName ( junk_tmp
).c_str () );
3100 GenerateBuildMapCode ( &junk_tmp
);
3101 fprintf ( fMakefile
,
3102 "\t-@${rm} %s 2>$(NUL)\n",
3103 backend
->GetFullName ( junk_tmp
).c_str () );
3109 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
3110 const Module
& module_
)
3111 : MingwModuleHandler ( module_
)
3116 MingwBootProgramModuleHandler::Process ()
3118 GenerateBootProgramModuleTarget ();
3122 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3124 string
targetName ( module
.output
->name
);
3125 string
targetMacro ( GetTargetMacro (module
) );
3126 string workingDirectory
= GetWorkingDirectory ();
3127 FileLocation
junk_tmp ( TemporaryDirectory
,
3129 module
.name
+ ".junk.tmp" );
3130 FileLocation
junk_elf ( TemporaryDirectory
,
3132 module
.name
+ ".junk.elf" );
3133 FileLocation
junk_cpy ( TemporaryDirectory
,
3135 module
.name
+ ".junk.elf" );
3136 CLEAN_FILE ( junk_tmp
);
3137 CLEAN_FILE ( junk_elf
);
3138 CLEAN_FILE ( junk_cpy
);
3139 string objectsMacro
= GetObjectsMacro ( module
);
3140 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3141 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3145 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
3147 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3148 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3149 targetMacro
.c_str (),
3150 objectsMacro
.c_str (),
3151 linkDepsMacro
.c_str (),
3152 payload
->name
.c_str (),
3153 backend
->GetFullPath ( *target_file
).c_str () );
3155 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3157 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3158 module
.buildtype
.c_str (),
3159 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3160 backend
->GetFullName ( junk_cpy
).c_str () );
3162 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3163 module
.buildtype
.c_str (),
3164 backend
->GetFullName ( junk_cpy
).c_str (),
3165 backend
->GetFullName ( junk_tmp
).c_str () );
3167 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
3168 module
.buildtype
.c_str (),
3169 linkDepsMacro
.c_str (),
3170 backend
->GetFullName ( junk_tmp
).c_str (),
3171 backend
->GetFullName ( junk_elf
).c_str () );
3173 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3174 module
.buildtype
.c_str (),
3175 backend
->GetFullName ( junk_elf
).c_str (),
3176 backend
->GetFullName ( *module
.output
) .c_str () );
3178 fprintf ( fMakefile
,
3179 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3180 backend
->GetFullName ( junk_tmp
).c_str (),
3181 backend
->GetFullName ( junk_elf
).c_str (),
3182 backend
->GetFullName ( junk_cpy
).c_str () );
3188 MingwIsoModuleHandler::MingwIsoModuleHandler (
3189 const Module
& module_
)
3191 : MingwModuleHandler ( module_
)
3196 MingwIsoModuleHandler::Process ()
3198 GenerateIsoModuleTarget ();
3202 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3203 const string
& bootcdDirectory
)
3205 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3207 const Module
& m
= *p
->second
;
3210 if ( m
.bootstrap
!= NULL
)
3212 FileLocation
targetFile ( OutputDirectory
,
3213 m
.bootstrap
->base
.length () > 0
3214 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3216 m
.bootstrap
->nameoncd
);
3217 OutputCopyCommand ( *m
.output
, targetFile
);
3223 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3224 const string
& bootcdDirectory
)
3226 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3228 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3229 FileLocation
targetFile ( OutputDirectory
,
3230 cdfile
.target
->relative_path
.length () > 0
3231 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3233 cdfile
.target
->name
);
3234 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3239 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3240 const string
& bootcdDirectory
)
3242 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3244 const Module
& m
= *p
->second
;
3247 if ( m
.bootstrap
!= NULL
)
3249 FileLocation
targetDirectory ( OutputDirectory
,
3250 m
.bootstrap
->base
.length () > 0
3251 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3254 out
.push_back ( targetDirectory
);
3260 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3261 const string
& bootcdDirectory
)
3263 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3265 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3266 FileLocation
targetDirectory ( OutputDirectory
,
3267 cdfile
.target
->relative_path
.length () > 0
3268 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3271 out
.push_back( targetDirectory
);
3276 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3277 const string
& bootcdDirectory
)
3279 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3280 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3284 MingwIsoModuleHandler::GetBootstrapCdFiles (
3285 vector
<FileLocation
>& out
) const
3287 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3289 const Module
& m
= *p
->second
;
3292 if ( m
.bootstrap
!= NULL
)
3294 out
.push_back ( *m
.output
);
3300 MingwIsoModuleHandler::GetNonModuleCdFiles (
3301 vector
<FileLocation
>& out
) const
3303 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3305 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3306 out
.push_back ( *cdfile
.source
);
3311 MingwIsoModuleHandler::GetCdFiles (
3312 vector
<FileLocation
>& out
) const
3314 GetBootstrapCdFiles ( out
);
3315 GetNonModuleCdFiles ( out
);
3319 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3321 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
3322 string bootcdDirectory
= "cd";
3323 FileLocation
bootcd ( OutputDirectory
,
3326 FileLocation
bootcdReactos ( OutputDirectory
,
3327 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3329 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3330 vector
<FileLocation
> vCdDirectories
;
3333 FileLocation
srcunattend ( SourceDirectory
,
3334 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3336 FileLocation
tarunattend ( bootcdReactos
.directory
,
3337 bootcdReactos
.relative_path
,
3339 if (module
.type
== IsoRegTest
)
3340 vSourceFiles
.push_back ( srcunattend
);
3343 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3347 throw InvalidOperationException ( module
.node
.location
.c_str(),
3349 "Invalid bootsector. module '%s' requires <bootsector>",
3350 module
.name
.c_str ());
3353 const FileLocation
*isoboot
= bootModule
->output
;
3354 vSourceFiles
.push_back ( *isoboot
);
3356 // prepare reactos.dff and reactos.inf
3357 FileLocation
reactosDff ( SourceDirectory
,
3358 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3360 FileLocation
reactosInf ( bootcdReactos
.directory
,
3361 bootcdReactos
.relative_path
,
3364 vSourceFiles
.push_back ( reactosDff
);
3367 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3368 Iso/LiveIso outputs are generated in code base root
3370 string IsoName
= module
.output
->name
;
3372 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3375 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3376 GetCdFiles ( vCdFiles
);
3377 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3378 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3380 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3381 module
.name
.c_str ());
3382 fprintf ( fMakefile
,
3383 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3384 module
.name
.c_str (),
3385 backend
->GetFullName ( *isoboot
).c_str (),
3386 sourceFiles
.c_str (),
3388 cdDirectories
.c_str () );
3389 fprintf ( fMakefile
,
3390 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3391 backend
->GetFullName ( reactosDff
).c_str (),
3392 backend
->GetFullPath ( bootcdReactos
).c_str () );
3393 fprintf ( fMakefile
,
3394 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3395 backend
->GetFullName ( reactosDff
).c_str (),
3396 backend
->GetFullName ( reactosInf
).c_str (),
3397 backend
->GetFullPath ( bootcdReactos
).c_str ());
3398 fprintf ( fMakefile
,
3399 "\t-@${rm} %s 2>$(NUL)\n",
3400 backend
->GetFullName ( reactosInf
).c_str () );
3401 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3402 OutputCdfileCopyCommands ( bootcdDirectory
);
3404 if (module
.type
== IsoRegTest
)
3405 OutputCopyCommand ( srcunattend
, tarunattend
);
3407 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3408 fprintf ( fMakefile
,
3409 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3410 backend
->GetFullName ( *isoboot
).c_str (),
3411 backend
->GetFullPath ( bootcd
).c_str (),
3413 fprintf ( fMakefile
,
3418 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3419 const Module
& module_
)
3421 : MingwModuleHandler ( module_
)
3426 MingwLiveIsoModuleHandler::Process ()
3428 GenerateLiveIsoModuleTarget ();
3432 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3434 FileLocation
dir ( OutputDirectory
,
3437 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3441 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3442 string
& reactosDirectory
)
3444 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3446 const Module
& m
= *p
->second
;
3451 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3452 FileLocation
destination ( OutputDirectory
,
3453 m
.install
->relative_path
.length () > 0
3454 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3455 : livecdDirectory
+ sSep
+ reactosDirectory
,
3457 OutputCopyCommand ( *aliasedModule
.output
,
3464 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3465 string
& reactosDirectory
)
3467 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3469 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3470 FileLocation
target ( OutputDirectory
,
3471 installfile
.target
->relative_path
.length () > 0
3472 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3473 : livecdDirectory
+ sSep
+ reactosDirectory
,
3474 installfile
.target
->name
);
3475 OutputCopyCommand ( *installfile
.source
, target
);
3480 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3482 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3483 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3484 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3485 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3486 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3487 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3489 FileLocation
livecdIni ( SourceDirectory
,
3490 "boot" + sSep
+ "bootdata",
3492 FileLocation
destination ( OutputDirectory
,
3495 OutputCopyCommand ( livecdIni
,
3500 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3502 FileLocation
freeldr ( OutputDirectory
,
3503 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3505 FileLocation
destination ( OutputDirectory
,
3506 livecdDirectory
+ sSep
+ "loader",
3508 OutputCopyCommand ( freeldr
,
3513 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3515 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
3516 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3517 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3519 fprintf ( fMakefile
,
3520 "\t$(ECHO_MKHIVE)\n" );
3521 fprintf ( fMakefile
,
3522 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3523 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3524 cSep
, cSep
, cSep
, cSep
);
3528 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3530 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3531 string livecdDirectory
= module
.name
;
3532 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3537 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3541 throw InvalidOperationException ( module
.node
.location
.c_str(),
3543 "Invalid bootsector. module '%s' requires <bootsector>",
3544 module
.name
.c_str ());
3547 const FileLocation
*isoboot
= bootModule
->output
;
3550 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3551 Iso/LiveIso outputs are generated in code base root
3553 IsoName
= module
.output
->name
;
3555 string reactosDirectory
= "reactos";
3556 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3557 FileLocation
livecdReactos ( OutputDirectory
,
3558 livecdReactosNoFixup
,
3560 CLEAN_FILE ( livecdReactos
);
3562 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3563 module
.name
.c_str ());
3564 fprintf ( fMakefile
,
3565 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3566 module
.name
.c_str (),
3567 backend
->GetFullName ( *isoboot
) .c_str (),
3568 backend
->GetFullPath ( livecdReactos
).c_str () );
3569 OutputModuleCopyCommands ( livecdDirectory
,
3571 OutputNonModuleCopyCommands ( livecdDirectory
,
3573 OutputProfilesDirectoryCommands ( livecdDirectory
);
3574 OutputLoaderCommands ( livecdDirectory
);
3575 OutputRegistryCommands ( livecdDirectory
);
3576 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3577 fprintf ( fMakefile
,
3578 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3579 backend
->GetFullName( *isoboot
).c_str (),
3580 backend
->GetFullPath ( livecd
).c_str (),
3582 fprintf ( fMakefile
,
3587 MingwTestModuleHandler::MingwTestModuleHandler (
3588 const Module
& module_
)
3590 : MingwModuleHandler ( module_
)
3595 MingwTestModuleHandler::Process ()
3597 GenerateTestModuleTarget ();
3600 /* caller needs to delete the returned object */
3602 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3604 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3605 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3606 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3610 MingwTestModuleHandler::GenerateTestModuleTarget ()
3612 string
targetMacro ( GetTargetMacro ( module
) );
3613 string workingDirectory
= GetWorkingDirectory ( );
3614 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3616 GenerateImportLibraryTargetIfNeeded ();
3618 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3622 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3624 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3625 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3626 module
.baseaddress
.c_str () );
3627 GenerateLinkerCommand ( dependencies
,
3633 GeneratePhonyTarget();
3638 MingwAliasModuleHandler::MingwAliasModuleHandler (
3639 const Module
& module_
)
3641 : MingwModuleHandler ( module_
)
3646 MingwAliasModuleHandler::Process ()
3651 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3652 const Module
& module_
)
3654 : MingwModuleHandler ( module_
)
3659 MingwCabinetModuleHandler::Process ()
3661 string
targetMacro ( GetTargetMacro (module
) );
3665 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3666 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3667 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3668 targetMacro
.c_str (),
3669 backend
->GetFullPath ( *target_file
).c_str () );
3671 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3672 fprintf ( fMakefile
,
3673 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3674 targetMacro
.c_str (),
3675 module
.name
.c_str());
3678 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3679 const Module
& module_
)
3681 : MingwModuleHandler ( module_
)
3686 MingwElfExecutableModuleHandler::Process ()
3688 string
targetName ( module
.output
->name
);
3689 string
targetMacro ( GetTargetMacro (module
) );
3690 string workingDirectory
= GetWorkingDirectory ();
3691 string objectsMacro
= GetObjectsMacro ( module
);
3692 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3693 string libsMacro
= GetLibsMacro ();
3694 string debugFormat
= GetDebugFormat ();
3698 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3699 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3700 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3701 targetMacro
.c_str (),
3702 objectsMacro
.c_str (),
3703 linkDepsMacro
.c_str (),
3704 backend
->GetFullPath ( *target_file
).c_str () );
3706 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3708 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g%s -o %s\n",
3709 module
.buildtype
.c_str(),
3710 objectsMacro
.c_str(),
3712 debugFormat
.c_str(),
3713 targetMacro
.c_str () );