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::GetModuleTargets ( const Module
& module
)
1880 if ( ReferenceObjects ( module
) )
1881 return GetObjectsMacro ( module
);
1884 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1885 string target
= backend
->GetFullName ( *target_file
).c_str ();
1892 MingwModuleHandler::GenerateSourceMacro ()
1894 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1896 GenerateSourceMacros ( module
.non_if_data
);
1898 // future references to the macro will be to get its values
1899 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1903 MingwModuleHandler::GenerateObjectMacro ()
1905 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1907 GenerateObjectMacros ( module
.non_if_data
);
1909 // future references to the macro will be to get its values
1910 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1914 MingwModuleHandler::GenerateTargetMacro ()
1916 fprintf ( fMakefile
, "# TARGET MACRO\n" );
1917 fprintf ( fMakefile
,
1919 GetTargetMacro ( module
, false ).c_str (),
1920 GetModuleTargets ( module
).c_str () );
1924 MingwModuleHandler::GetRpcHeaderDependencies (
1925 vector
<FileLocation
>& dependencies
) const
1927 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1929 Library
& library
= *module
.non_if_data
.libraries
[i
];
1930 if ( library
.importedModule
->type
== RpcServer
||
1931 library
.importedModule
->type
== RpcClient
||
1932 library
.importedModule
->type
== RpcProxy
||
1933 library
.importedModule
->type
== IdlHeader
)
1935 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1937 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1938 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1939 string extension
= GetExtension ( sourceFile
);
1940 if ( extension
== ".idl" || extension
== ".IDL" )
1942 string basename
= GetBasename ( sourceFile
.name
);
1943 if ( library
.importedModule
->type
== RpcServer
)
1945 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1946 dependencies
.push_back ( *header
);
1949 if ( library
.importedModule
->type
== RpcClient
)
1951 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1952 dependencies
.push_back ( *header
);
1955 if ( library
.importedModule
->type
== RpcProxy
)
1957 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1958 dependencies
.push_back ( *header
);
1961 if ( library
.importedModule
->type
== IdlHeader
)
1963 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1964 dependencies
.push_back ( *header
);
1974 MingwModuleHandler::GenerateOtherMacros ()
1976 set
<const Define
*> used_defs
;
1978 fprintf ( fMakefile
, "# OTHER MACROS\n" );
1980 commonflagsMacro
= ssprintf ("%s_COMMONFLAGS", module
.name
.c_str ());
1981 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1982 cxxflagsMacro
= ssprintf ("%s_CXXFLAGS", module
.name
.c_str ());
1983 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1984 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1985 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1986 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1987 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1988 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1993 &module
.linkerFlags
,
1996 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1998 GenerateMacros("+=", module
.project
.host_non_if_data
, NULL
, used_defs
);
2004 module
.project
.non_if_data
,
2009 if ( IsSpecDefinitionFile() )
2011 vector
<FileLocation
> s
;
2012 GetSpecImplibDependencies ( s
, module
.importLibrary
->source
);
2017 linkDepsMacro
.c_str() );
2018 for ( size_t i
= 0; i
< s
.size(); i
++ )
2019 fprintf ( fMakefile
,
2021 backend
->GetFullName ( s
[i
] ).c_str () );
2022 fprintf ( fMakefile
, "\n" );
2025 string globalCflags
= " ";
2026 globalCflags
+= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
2027 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
2029 if ( module
.dynamicCRT
)
2030 globalCflags
+= " -D_DLL -D__USE_CRTIMP";
2033 globalCflags
+= " -Wall -Wpointer-arith";
2034 globalCflags
+= " -gstabs+";
2035 if ( backend
->usePipe
)
2036 globalCflags
+= " -pipe";
2037 if ( !module
.allowWarnings
)
2038 globalCflags
+= " -Werror";
2039 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2041 if ( module
.cplusplus
)
2042 globalCflags
+= " $(HOST_CPPFLAGS)";
2044 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
2048 if ( module
.cplusplus
)
2050 globalCflags
+= " $(TARGET_CPPFLAGS)";
2053 globalCflags
+= " -nostdinc";
2056 // Always force disabling of sibling calls optimisation for GCC
2057 // (TODO: Move to version-specific once this bug is fixed in GCC)
2058 globalCflags
+= " -fno-optimize-sibling-calls";
2060 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
2065 cflagsMacro
.c_str (),
2066 (" $(PROJECT_CFLAGS)" + globalCflags
).c_str () );
2071 cxxflagsMacro
.c_str (),
2072 (" $(PROJECT_CXXFLAGS)" + globalCflags
).c_str () );
2076 "%s += $(PROJECT_RCFLAGS)\n",
2077 windresflagsMacro
.c_str () );
2081 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
2082 widlflagsMacro
.c_str (),
2083 module
.output
->relative_path
.c_str () );
2087 "%s_LFLAGS := $(PROJECT_LFLAGS) $(%s_LFLAGS)\n",
2088 module
.name
.c_str (),
2089 module
.name
.c_str () );
2096 cflagsMacro
.c_str (),
2097 globalCflags
.c_str () );
2102 cxxflagsMacro
.c_str (),
2103 globalCflags
.c_str () );
2107 "%s_LFLAGS += $(HOST_LFLAGS)\n",
2108 module
.name
.c_str () );
2114 linkDepsMacro
.c_str (),
2115 libsMacro
.c_str () );
2117 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
2118 if ( strlen( cflags
) > 0 )
2120 fprintf ( fMakefile
,
2122 cflagsMacro
.c_str (),
2124 fprintf ( fMakefile
,
2126 cxxflagsMacro
.c_str (),
2130 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
2131 if ( strlen( nasmflags
) > 0 )
2133 fprintf ( fMakefile
,
2135 nasmflagsMacro
.c_str (),
2139 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
2140 if ( strlen( linkerflags
) > 0 )
2142 fprintf ( fMakefile
,
2144 linkerflagsMacro
.c_str (),
2148 fprintf ( fMakefile
, "\n\n" );
2150 // future references to the macros will be to get their values
2151 commonflagsMacro
= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
2152 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2153 cxxflagsMacro
= ssprintf ("$(%s)", cxxflagsMacro
.c_str ());
2154 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2155 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2159 MingwModuleHandler::GenerateRules ()
2163 fprintf ( fMakefile
, "# RULES\n" );
2164 string targetMacro
= GetTargetMacro ( module
);
2165 //CLEAN_FILE ( targetMacro );
2166 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2168 // generate phony target for module name
2169 fprintf ( fMakefile
, ".PHONY: %s\n",
2170 module
.name
.c_str () );
2171 string dependencies
= GetTargetMacro ( module
);
2172 if ( module
.type
== Test
)
2173 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2174 fprintf ( fMakefile
, "%s: %s\n\n",
2175 module
.name
.c_str (),
2176 dependencies
.c_str () );
2177 if ( module
.type
== Test
)
2179 fprintf ( fMakefile
,
2181 targetMacro
.c_str ());
2184 if ( !ReferenceObjects ( module
) )
2186 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2191 spec
= IsSpecDefinitionFile();
2198 defRule
= &winebuildPDefRule
;
2200 defRule
= &winebuildDefRule
;
2202 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
2205 GenerateObjectFileTargets ();
2209 MingwModuleHandler::GetInvocationDependencies (
2210 const Module
& module
,
2211 string_list
& dependencies
)
2213 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2215 Invoke
& invoke
= *module
.invocations
[i
];
2216 if ( invoke
.invokeModule
== &module
)
2217 /* Protect against circular dependencies */
2219 invoke
.GetTargets ( dependencies
);
2224 MingwModuleHandler::GenerateInvocations () const
2226 if ( module
.invocations
.size () == 0 )
2229 fprintf ( fMakefile
, "# INVOCATIONS\n" );
2231 size_t iend
= module
.invocations
.size ();
2232 for ( size_t i
= 0; i
< iend
; i
++ )
2234 const Invoke
& invoke
= *module
.invocations
[i
];
2236 if ( invoke
.invokeModule
->type
!= BuildTool
)
2238 throw XMLInvalidBuildFileException (
2239 module
.node
.location
,
2240 "Only modules of type buildtool can be invoked." );
2243 string invokeTarget
= module
.GetInvocationTarget ( i
);
2244 string_list invoke_targets
;
2245 assert ( invoke_targets
.size() );
2246 invoke
.GetTargets ( invoke_targets
);
2247 fprintf ( fMakefile
,
2249 invokeTarget
.c_str () );
2250 fprintf ( fMakefile
,
2252 invokeTarget
.c_str () );
2253 size_t j
, jend
= invoke_targets
.size();
2254 for ( j
= 0; j
< jend
; j
++ )
2256 fprintf ( fMakefile
,
2258 invoke_targets
[i
].c_str () );
2260 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2261 for ( j
= 1; j
< jend
; j
++ )
2262 fprintf ( fMakefile
,
2264 invoke_targets
[i
].c_str () );
2265 fprintf ( fMakefile
,
2267 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2268 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2269 fprintf ( fMakefile
,
2271 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2272 invoke
.GetParameters ().c_str () );
2277 MingwModuleHandler::GetPreconditionDependenciesName () const
2279 return module
.name
+ "_precondition";
2283 MingwModuleHandler::GetDefaultDependencies (
2284 string_list
& dependencies
) const
2286 /* Avoid circular dependency */
2287 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2290 if (module
.name
!= "psdk" &&
2291 module
.name
!= "dxsdk")
2293 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2294 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2297 if (module
.name
!= "errcodes" &&
2298 module
.name
!= "bugcodes" &&
2299 module
.name
!= "ntstatus")
2301 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2302 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2303 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2306 ///* Check if any dependent library relies on the generated headers */
2307 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2309 // const Module& m = *module.project.modules[i];
2310 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2312 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2313 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2314 // string extension = GetExtension ( sourceFile );
2315 // if (extension == ".mc" || extension == ".MC" )
2317 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2318 // dependencies.push_back ( dependency );
2325 MingwModuleHandler::GeneratePreconditionDependencies ()
2327 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
2328 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2329 string_list dependencies
;
2330 GetDefaultDependencies ( dependencies
);
2331 GetModuleDependencies ( dependencies
);
2333 GetInvocationDependencies ( module
, dependencies
);
2335 if ( dependencies
.size() )
2337 fprintf ( fMakefile
,
2339 preconditionDependenciesName
.c_str () );
2340 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2341 fprintf ( fMakefile
,
2343 dependencies
[i
].c_str () );
2344 fprintf ( fMakefile
, "\n\n" );
2347 fprintf ( fMakefile
, "\n" );
2351 MingwModuleHandler::IsSpecDefinitionFile () const
2353 if(!module
.importLibrary
)
2356 std::string ext
= GetExtension ( *module
.importLibrary
->source
);
2358 if ( ext
== ".spec" )
2361 if ( ext
== ".pspec" )
2367 /* caller needs to delete the returned object */
2369 MingwModuleHandler::GetDefinitionFilename () const
2371 if ( module
.importLibrary
== NULL
)
2374 if ( IsSpecDefinitionFile () )
2376 return new FileLocation ( IntermediateDirectory
,
2377 module
.importLibrary
->source
->relative_path
,
2378 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2382 return new FileLocation ( SourceDirectory
,
2383 module
.importLibrary
->source
->relative_path
,
2384 module
.importLibrary
->source
->name
);
2389 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2391 if ( module
.importLibrary
!= NULL
)
2393 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2394 const FileLocation
*defFilename
= GetDefinitionFilename ();
2395 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2397 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE\n" );
2399 fprintf ( fMakefile
, "%s:",
2400 backend
->GetFullName ( *library_target
).c_str () );
2404 fprintf ( fMakefile
, " %s",
2405 backend
->GetFullName ( *defFilename
).c_str () );
2408 fprintf ( fMakefile
, " | %s\n",
2409 backend
->GetFullPath ( *library_target
).c_str () );
2411 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2413 fprintf ( fMakefile
,
2414 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2415 module
.GetDllName ().c_str (),
2416 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2418 backend
->GetFullName ( *library_target
).c_str (),
2419 module
.mangledSymbols
? "" : " --kill-at",
2420 module
.underscoreSymbols
? " --add-underscore" : "" );
2424 delete library_target
;
2429 MingwModuleHandler::GetSpecObjectDependencies (
2430 vector
<FileLocation
>& dependencies
,
2431 const FileLocation
*file
) const
2433 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2434 file
->relative_path
,
2435 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2439 MingwModuleHandler::GetSpecImplibDependencies (
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
+ ".auto.def" ) );
2449 MingwModuleHandler::GetMcObjectDependencies (
2450 vector
<FileLocation
>& dependencies
,
2451 const FileLocation
*file
) const
2453 string basename
= GetBasename ( file
->name
);
2455 FileLocation
defDependency ( IntermediateDirectory
,
2458 dependencies
.push_back ( defDependency
);
2460 FileLocation
stubsDependency ( IntermediateDirectory
,
2461 file
->relative_path
,
2463 dependencies
.push_back ( stubsDependency
);
2467 MingwModuleHandler::GetWidlObjectDependencies (
2468 vector
<FileLocation
>& dependencies
,
2469 const FileLocation
*file
) const
2471 string basename
= GetBasename ( file
->name
);
2472 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2474 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2475 file
->relative_path
,
2476 basename
+ "_s.c" );
2477 dependencies
.push_back ( serverSourceDependency
);
2478 dependencies
.push_back ( *generatedHeaderFilename
);
2480 delete generatedHeaderFilename
;
2484 MingwModuleHandler::GetDefinitionDependencies (
2485 vector
<FileLocation
>& dependencies
) const
2487 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2488 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2490 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2491 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2492 string extension
= GetExtension ( sourceFile
);
2494 if (extension
== ".spec" || extension
== ".pspec")
2495 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2497 if (extension
== ".idl")
2499 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2500 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2505 enum DebugSupportType
2512 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2518 case DebugKernelMode
:
2519 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2523 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2530 module
.non_if_data
.libraries
.push_back(pLibrary
);
2534 MingwAddCRTLibrary( Module
&module
)
2536 const char * crtAttr
= module
.CRT
.c_str ();
2537 const char * crtLib
= NULL
;
2539 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2541 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2543 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2544 crtLib
= "libcntpr";
2545 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2550 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2552 if ( pLibrary
->importedModule
== NULL
)
2554 throw XMLInvalidBuildFileException (
2555 module
.node
.location
,
2556 "module '%s' trying to import non-existant C runtime module '%s'",
2557 module
.name
.c_str(),
2561 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2565 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2566 : MingwModuleHandler ( module_
)
2571 MingwBuildToolModuleHandler::Process ()
2573 GenerateBuildToolModuleTarget ();
2577 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2579 string
targetMacro ( GetTargetMacro (module
) );
2580 string objectsMacro
= GetObjectsMacro ( module
);
2581 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2582 string libsMacro
= GetLibsMacro ();
2586 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2589 if ( module
.cplusplus
)
2590 linker
= "${host_gpp}";
2592 linker
= "${host_gcc}";
2594 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2595 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2596 targetMacro
.c_str (),
2597 objectsMacro
.c_str (),
2598 linkDepsMacro
.c_str (),
2599 backend
->GetFullPath ( *target_file
).c_str () );
2600 fprintf ( fMakefile
, "\t$(ECHO_HOSTLD)\n" );
2601 fprintf ( fMakefile
,
2602 "\t%s %s -o $@ %s %s\n\n",
2604 GetLinkerMacro ().c_str (),
2605 objectsMacro
.c_str (),
2606 libsMacro
.c_str () );
2612 MingwKernelModuleHandler::MingwKernelModuleHandler (
2613 const Module
& module_
)
2615 : MingwModuleHandler ( module_
)
2620 MingwKernelModuleHandler::Process ()
2622 GenerateKernelModuleTarget ();
2626 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2628 string
targetMacro ( GetTargetMacro ( module
) );
2629 string workingDirectory
= GetWorkingDirectory ( );
2630 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2632 GenerateImportLibraryTargetIfNeeded ();
2634 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2638 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2640 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2641 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2642 module
.baseaddress
.c_str () );
2644 GenerateLinkerCommand ( dependencies
,
2645 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2650 GeneratePhonyTarget();
2655 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2656 const Module
& module_
)
2658 : MingwModuleHandler ( module_
)
2664 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2666 MingwAddCRTLibrary ( module
);
2667 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2671 MingwKernelModeDLLModuleHandler::Process ()
2673 GenerateKernelModeDLLModuleTarget ();
2677 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2679 string
targetMacro ( GetTargetMacro ( module
) );
2680 string workingDirectory
= GetWorkingDirectory ();
2681 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2683 GenerateImportLibraryTargetIfNeeded ();
2685 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2689 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2691 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2692 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2693 module
.baseaddress
.c_str () );
2694 GenerateLinkerCommand ( dependencies
,
2700 GeneratePhonyTarget();
2705 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2706 const Module
& module_
)
2708 : MingwModuleHandler ( module_
)
2713 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2715 MingwAddCRTLibrary ( module
);
2716 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2720 MingwNativeDLLModuleHandler::Process ()
2722 GenerateNativeDLLModuleTarget ();
2726 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2728 string
targetMacro ( GetTargetMacro (module
) );
2729 string workingDirectory
= GetWorkingDirectory ( );
2730 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2732 GenerateImportLibraryTargetIfNeeded ();
2734 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2738 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2740 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2741 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2742 module
.baseaddress
.c_str () );
2743 GenerateLinkerCommand ( dependencies
,
2749 GeneratePhonyTarget();
2754 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2755 const Module
& module_
)
2757 : MingwModuleHandler ( module_
)
2762 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2764 MingwAddCRTLibrary ( module
);
2765 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2769 MingwNativeCUIModuleHandler::Process ()
2771 GenerateNativeCUIModuleTarget ();
2775 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2777 string
targetMacro ( GetTargetMacro (module
) );
2778 string workingDirectory
= GetWorkingDirectory ( );
2779 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2781 GenerateImportLibraryTargetIfNeeded ();
2783 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2787 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2789 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2790 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2791 module
.baseaddress
.c_str () );
2792 GenerateLinkerCommand ( dependencies
,
2798 GeneratePhonyTarget();
2803 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2804 const Module
& module_
)
2806 : MingwModuleHandler ( module_
)
2810 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2811 const Module
& module_
)
2813 : MingwModuleHandler ( module_
)
2818 MingwAddImplicitLibraries( Module
&module
)
2822 if ( module
.type
!= Win32DLL
2823 && module
.type
!= Win32OCX
2824 && module
.type
!= Win32CUI
2825 && module
.type
!= Win32GUI
2826 && module
.type
!= Win32SCR
)
2831 if ( module
.isDefaultEntryPoint
)
2833 if ( module
.IsDLL () )
2835 //pLibrary = new Library ( module, "__mingw_dllmain" );
2836 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2840 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2841 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2845 pLibrary
= new Library ( module
, "mingw_common" );
2846 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2848 MingwAddCRTLibrary ( module
);
2849 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2853 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2855 MingwAddImplicitLibraries ( module
);
2859 MingwWin32DLLModuleHandler::Process ()
2861 GenerateWin32DLLModuleTarget ();
2865 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2867 string
targetMacro ( GetTargetMacro (module
) );
2868 string workingDirectory
= GetWorkingDirectory ( );
2869 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2871 GenerateImportLibraryTargetIfNeeded ();
2873 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2877 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2879 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2880 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2881 module
.baseaddress
.c_str () );
2882 GenerateLinkerCommand ( dependencies
,
2888 GeneratePhonyTarget();
2894 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2896 MingwAddImplicitLibraries ( module
);
2900 MingwWin32OCXModuleHandler::Process ()
2902 GenerateWin32OCXModuleTarget ();
2906 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2908 string
targetMacro ( GetTargetMacro (module
) );
2909 string workingDirectory
= GetWorkingDirectory ( );
2910 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2912 GenerateImportLibraryTargetIfNeeded ();
2914 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2918 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2920 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2921 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2922 module
.baseaddress
.c_str () );
2923 GenerateLinkerCommand ( dependencies
,
2929 GeneratePhonyTarget();
2934 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2935 const Module
& module_
)
2937 : MingwModuleHandler ( module_
)
2942 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2944 MingwAddImplicitLibraries ( module
);
2948 MingwWin32CUIModuleHandler::Process ()
2950 GenerateWin32CUIModuleTarget ();
2954 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2956 string
targetMacro ( GetTargetMacro (module
) );
2957 string workingDirectory
= GetWorkingDirectory ( );
2958 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2960 GenerateImportLibraryTargetIfNeeded ();
2962 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2966 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2968 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2969 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2970 module
.baseaddress
.c_str () );
2971 GenerateLinkerCommand ( dependencies
,
2977 GeneratePhonyTarget();
2982 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2983 const Module
& module_
)
2985 : MingwModuleHandler ( module_
)
2990 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2992 MingwAddImplicitLibraries ( module
);
2996 MingwWin32GUIModuleHandler::Process ()
2998 GenerateWin32GUIModuleTarget ();
3002 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
3004 string
targetMacro ( GetTargetMacro (module
) );
3005 string workingDirectory
= GetWorkingDirectory ( );
3006 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3008 GenerateImportLibraryTargetIfNeeded ();
3010 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3014 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3016 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3017 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3018 module
.baseaddress
.c_str () );
3019 GenerateLinkerCommand ( dependencies
,
3025 GeneratePhonyTarget();
3030 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
3031 const Module
& module_
)
3033 : MingwModuleHandler ( module_
)
3038 MingwBootLoaderModuleHandler::Process ()
3040 GenerateBootLoaderModuleTarget ();
3044 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
3046 string
targetName ( module
.output
->name
);
3047 string
targetMacro ( GetTargetMacro (module
) );
3048 string workingDirectory
= GetWorkingDirectory ();
3049 FileLocation
junk_tmp ( TemporaryDirectory
,
3051 module
.name
+ ".junk.tmp" );
3052 CLEAN_FILE ( junk_tmp
);
3053 string objectsMacro
= GetObjectsMacro ( module
);
3054 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3058 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
3060 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3061 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3062 targetMacro
.c_str (),
3063 objectsMacro
.c_str (),
3064 linkDepsMacro
.c_str (),
3065 backend
->GetFullPath ( *target_file
).c_str () );
3067 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
3069 if (Environment::GetArch() == "arm")
3071 fprintf ( fMakefile
,
3072 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
3073 backend
->GetFullName ( junk_tmp
).c_str (),
3074 objectsMacro
.c_str (),
3075 linkDepsMacro
.c_str (),
3076 GetLinkerMacro ().c_str ());
3080 fprintf ( fMakefile
,
3081 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
3082 backend
->GetFullName ( junk_tmp
).c_str (),
3083 objectsMacro
.c_str (),
3084 linkDepsMacro
.c_str (),
3085 GetLinkerMacro ().c_str ());
3087 fprintf ( fMakefile
,
3088 "\t${objcopy} -O binary %s $@\n",
3089 backend
->GetFullName ( junk_tmp
).c_str () );
3090 GenerateBuildMapCode ( &junk_tmp
);
3091 fprintf ( fMakefile
,
3092 "\t-@${rm} %s 2>$(NUL)\n",
3093 backend
->GetFullName ( junk_tmp
).c_str () );
3099 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
3100 const Module
& module_
)
3101 : MingwModuleHandler ( module_
)
3106 MingwBootProgramModuleHandler::Process ()
3108 GenerateBootProgramModuleTarget ();
3112 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3114 string
targetName ( module
.output
->name
);
3115 string
targetMacro ( GetTargetMacro (module
) );
3116 string workingDirectory
= GetWorkingDirectory ();
3117 FileLocation
junk_tmp ( TemporaryDirectory
,
3119 module
.name
+ ".junk.tmp" );
3120 FileLocation
junk_elf ( TemporaryDirectory
,
3122 module
.name
+ ".junk.elf" );
3123 FileLocation
junk_cpy ( TemporaryDirectory
,
3125 module
.name
+ ".junk.elf" );
3126 CLEAN_FILE ( junk_tmp
);
3127 CLEAN_FILE ( junk_elf
);
3128 CLEAN_FILE ( junk_cpy
);
3129 string objectsMacro
= GetObjectsMacro ( module
);
3130 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3131 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3135 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
3137 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3138 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3139 targetMacro
.c_str (),
3140 objectsMacro
.c_str (),
3141 linkDepsMacro
.c_str (),
3142 payload
->name
.c_str (),
3143 backend
->GetFullPath ( *target_file
).c_str () );
3145 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3147 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3148 module
.buildtype
.c_str (),
3149 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3150 backend
->GetFullName ( junk_cpy
).c_str () );
3152 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3153 module
.buildtype
.c_str (),
3154 backend
->GetFullName ( junk_cpy
).c_str (),
3155 backend
->GetFullName ( junk_tmp
).c_str () );
3157 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
3158 module
.buildtype
.c_str (),
3159 linkDepsMacro
.c_str (),
3160 backend
->GetFullName ( junk_tmp
).c_str (),
3161 backend
->GetFullName ( junk_elf
).c_str () );
3163 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3164 module
.buildtype
.c_str (),
3165 backend
->GetFullName ( junk_elf
).c_str (),
3166 backend
->GetFullName ( *module
.output
) .c_str () );
3168 fprintf ( fMakefile
,
3169 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3170 backend
->GetFullName ( junk_tmp
).c_str (),
3171 backend
->GetFullName ( junk_elf
).c_str (),
3172 backend
->GetFullName ( junk_cpy
).c_str () );
3178 MingwIsoModuleHandler::MingwIsoModuleHandler (
3179 const Module
& module_
)
3181 : MingwModuleHandler ( module_
)
3186 MingwIsoModuleHandler::Process ()
3188 GenerateIsoModuleTarget ();
3192 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3193 const string
& bootcdDirectory
)
3195 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3197 const Module
& m
= *p
->second
;
3200 if ( m
.bootstrap
!= NULL
)
3202 FileLocation
targetFile ( OutputDirectory
,
3203 m
.bootstrap
->base
.length () > 0
3204 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3206 m
.bootstrap
->nameoncd
);
3207 OutputCopyCommand ( *m
.output
, targetFile
);
3213 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3214 const string
& bootcdDirectory
)
3216 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3218 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3219 FileLocation
targetFile ( OutputDirectory
,
3220 cdfile
.target
->relative_path
.length () > 0
3221 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3223 cdfile
.target
->name
);
3224 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3229 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3230 const string
& bootcdDirectory
)
3232 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3234 const Module
& m
= *p
->second
;
3237 if ( m
.bootstrap
!= NULL
)
3239 FileLocation
targetDirectory ( OutputDirectory
,
3240 m
.bootstrap
->base
.length () > 0
3241 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3244 out
.push_back ( targetDirectory
);
3250 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3251 const string
& bootcdDirectory
)
3253 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3255 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3256 FileLocation
targetDirectory ( OutputDirectory
,
3257 cdfile
.target
->relative_path
.length () > 0
3258 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3261 out
.push_back( targetDirectory
);
3266 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3267 const string
& bootcdDirectory
)
3269 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3270 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3274 MingwIsoModuleHandler::GetBootstrapCdFiles (
3275 vector
<FileLocation
>& out
) const
3277 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3279 const Module
& m
= *p
->second
;
3282 if ( m
.bootstrap
!= NULL
)
3284 out
.push_back ( *m
.output
);
3290 MingwIsoModuleHandler::GetNonModuleCdFiles (
3291 vector
<FileLocation
>& out
) const
3293 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3295 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3296 out
.push_back ( *cdfile
.source
);
3301 MingwIsoModuleHandler::GetCdFiles (
3302 vector
<FileLocation
>& out
) const
3304 GetBootstrapCdFiles ( out
);
3305 GetNonModuleCdFiles ( out
);
3309 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3311 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
3312 string bootcdDirectory
= "cd";
3313 FileLocation
bootcd ( OutputDirectory
,
3316 FileLocation
bootcdReactos ( OutputDirectory
,
3317 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3319 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3320 vector
<FileLocation
> vCdDirectories
;
3323 FileLocation
srcunattend ( SourceDirectory
,
3324 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3326 FileLocation
tarunattend ( bootcdReactos
.directory
,
3327 bootcdReactos
.relative_path
,
3329 if (module
.type
== IsoRegTest
)
3330 vSourceFiles
.push_back ( srcunattend
);
3333 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3337 throw InvalidOperationException ( module
.node
.location
.c_str(),
3339 "Invalid bootsector. module '%s' requires <bootsector>",
3340 module
.name
.c_str ());
3343 const FileLocation
*isoboot
= bootModule
->output
;
3344 vSourceFiles
.push_back ( *isoboot
);
3346 // prepare reactos.dff and reactos.inf
3347 FileLocation
reactosDff ( SourceDirectory
,
3348 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3350 FileLocation
reactosInf ( bootcdReactos
.directory
,
3351 bootcdReactos
.relative_path
,
3354 vSourceFiles
.push_back ( reactosDff
);
3357 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3358 Iso/LiveIso outputs are generated in code base root
3360 string IsoName
= module
.output
->name
;
3362 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3365 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3366 GetCdFiles ( vCdFiles
);
3367 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3368 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3370 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3371 module
.name
.c_str ());
3372 fprintf ( fMakefile
,
3373 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3374 module
.name
.c_str (),
3375 backend
->GetFullName ( *isoboot
).c_str (),
3376 sourceFiles
.c_str (),
3378 cdDirectories
.c_str () );
3379 fprintf ( fMakefile
,
3380 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3381 backend
->GetFullName ( reactosDff
).c_str (),
3382 backend
->GetFullPath ( bootcdReactos
).c_str () );
3383 fprintf ( fMakefile
,
3384 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3385 backend
->GetFullName ( reactosDff
).c_str (),
3386 backend
->GetFullName ( reactosInf
).c_str (),
3387 backend
->GetFullPath ( bootcdReactos
).c_str ());
3388 fprintf ( fMakefile
,
3389 "\t-@${rm} %s 2>$(NUL)\n",
3390 backend
->GetFullName ( reactosInf
).c_str () );
3391 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3392 OutputCdfileCopyCommands ( bootcdDirectory
);
3394 if (module
.type
== IsoRegTest
)
3395 OutputCopyCommand ( srcunattend
, tarunattend
);
3397 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3398 fprintf ( fMakefile
,
3399 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3400 backend
->GetFullName ( *isoboot
).c_str (),
3401 backend
->GetFullPath ( bootcd
).c_str (),
3403 fprintf ( fMakefile
,
3408 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3409 const Module
& module_
)
3411 : MingwModuleHandler ( module_
)
3416 MingwLiveIsoModuleHandler::Process ()
3418 GenerateLiveIsoModuleTarget ();
3422 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3424 FileLocation
dir ( OutputDirectory
,
3427 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3431 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3432 string
& reactosDirectory
)
3434 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3436 const Module
& m
= *p
->second
;
3441 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3442 FileLocation
destination ( OutputDirectory
,
3443 m
.install
->relative_path
.length () > 0
3444 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3445 : livecdDirectory
+ sSep
+ reactosDirectory
,
3447 OutputCopyCommand ( *aliasedModule
.output
,
3454 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3455 string
& reactosDirectory
)
3457 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3459 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3460 FileLocation
target ( OutputDirectory
,
3461 installfile
.target
->relative_path
.length () > 0
3462 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3463 : livecdDirectory
+ sSep
+ reactosDirectory
,
3464 installfile
.target
->name
);
3465 OutputCopyCommand ( *installfile
.source
, target
);
3470 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3472 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3473 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3474 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3475 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3476 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3477 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3479 FileLocation
livecdIni ( SourceDirectory
,
3480 "boot" + sSep
+ "bootdata",
3482 FileLocation
destination ( OutputDirectory
,
3485 OutputCopyCommand ( livecdIni
,
3490 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3492 FileLocation
freeldr ( OutputDirectory
,
3493 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3495 FileLocation
destination ( OutputDirectory
,
3496 livecdDirectory
+ sSep
+ "loader",
3498 OutputCopyCommand ( freeldr
,
3503 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3505 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
3506 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3507 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3509 fprintf ( fMakefile
,
3510 "\t$(ECHO_MKHIVE)\n" );
3511 fprintf ( fMakefile
,
3512 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3513 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3514 cSep
, cSep
, cSep
, cSep
);
3518 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3520 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3521 string livecdDirectory
= module
.name
;
3522 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3527 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3531 throw InvalidOperationException ( module
.node
.location
.c_str(),
3533 "Invalid bootsector. module '%s' requires <bootsector>",
3534 module
.name
.c_str ());
3537 const FileLocation
*isoboot
= bootModule
->output
;
3540 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3541 Iso/LiveIso outputs are generated in code base root
3543 IsoName
= module
.output
->name
;
3545 string reactosDirectory
= "reactos";
3546 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3547 FileLocation
livecdReactos ( OutputDirectory
,
3548 livecdReactosNoFixup
,
3550 CLEAN_FILE ( livecdReactos
);
3552 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3553 module
.name
.c_str ());
3554 fprintf ( fMakefile
,
3555 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3556 module
.name
.c_str (),
3557 backend
->GetFullName ( *isoboot
) .c_str (),
3558 backend
->GetFullPath ( livecdReactos
).c_str () );
3559 OutputModuleCopyCommands ( livecdDirectory
,
3561 OutputNonModuleCopyCommands ( livecdDirectory
,
3563 OutputProfilesDirectoryCommands ( livecdDirectory
);
3564 OutputLoaderCommands ( livecdDirectory
);
3565 OutputRegistryCommands ( livecdDirectory
);
3566 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3567 fprintf ( fMakefile
,
3568 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3569 backend
->GetFullName( *isoboot
).c_str (),
3570 backend
->GetFullPath ( livecd
).c_str (),
3572 fprintf ( fMakefile
,
3577 MingwTestModuleHandler::MingwTestModuleHandler (
3578 const Module
& module_
)
3580 : MingwModuleHandler ( module_
)
3585 MingwTestModuleHandler::Process ()
3587 GenerateTestModuleTarget ();
3590 /* caller needs to delete the returned object */
3592 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3594 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3595 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3596 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3600 MingwTestModuleHandler::GenerateTestModuleTarget ()
3602 string
targetMacro ( GetTargetMacro ( module
) );
3603 string workingDirectory
= GetWorkingDirectory ( );
3604 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3606 GenerateImportLibraryTargetIfNeeded ();
3608 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3612 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3614 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3615 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3616 module
.baseaddress
.c_str () );
3617 GenerateLinkerCommand ( dependencies
,
3623 GeneratePhonyTarget();
3628 MingwAliasModuleHandler::MingwAliasModuleHandler (
3629 const Module
& module_
)
3631 : MingwModuleHandler ( module_
)
3636 MingwAliasModuleHandler::Process ()
3641 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3642 const Module
& module_
)
3644 : MingwModuleHandler ( module_
)
3649 MingwCabinetModuleHandler::Process ()
3651 string
targetMacro ( GetTargetMacro (module
) );
3655 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3656 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3657 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3658 targetMacro
.c_str (),
3659 backend
->GetFullPath ( *target_file
).c_str () );
3661 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3662 fprintf ( fMakefile
,
3663 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3664 targetMacro
.c_str (),
3665 module
.name
.c_str());
3668 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3669 const Module
& module_
)
3671 : MingwModuleHandler ( module_
)
3676 MingwElfExecutableModuleHandler::Process ()
3678 string
targetName ( module
.output
->name
);
3679 string
targetMacro ( GetTargetMacro (module
) );
3680 string workingDirectory
= GetWorkingDirectory ();
3681 string objectsMacro
= GetObjectsMacro ( module
);
3682 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3683 string libsMacro
= GetLibsMacro ();
3687 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3688 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3689 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3690 targetMacro
.c_str (),
3691 objectsMacro
.c_str (),
3692 linkDepsMacro
.c_str (),
3693 backend
->GetFullPath ( *target_file
).c_str () );
3695 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3697 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -gstabs+ -o %s\n",
3698 module
.buildtype
.c_str(),
3699 objectsMacro
.c_str(),
3701 targetMacro
.c_str () );