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 () );
1016 /* caller needs to delete the returned object */
1018 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1020 if ( !module
.pch
|| !use_pch
)
1022 return new FileLocation ( IntermediateDirectory
,
1023 module
.pch
->file
->relative_path
+ "/.gch_" + module
.name
,
1024 module
.pch
->file
->name
+ ".gch" );
1027 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) $(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1028 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1029 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1030 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1031 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1033 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1034 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1036 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1037 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1039 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1040 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1041 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1042 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1043 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1045 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1046 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1047 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1048 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1050 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1051 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1052 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1053 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1054 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1056 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1057 "\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"
1058 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1059 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1060 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1061 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1062 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1063 Rule
wmcRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(WMC_TARGET) $(source) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1065 "\t$(Q)$(WMC_TARGET) -i -H $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h -o $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(source)\n",
1066 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1067 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1068 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1069 Rule
winebuildPDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1071 "\t${gcc} -xc -E ${$(module_name)_RCFLAGS} $(source) > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec\n\n"
1072 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1073 "\t$(ECHO_WINEBLD)\n"
1074 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def --def -E $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec --filename $(module_dllname)\n\n",
1075 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec",
1076 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1077 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1078 Rule
winebuildPRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1079 "\t$(ECHO_WINEBLD)\n"
1080 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec --filename $(module_dllname)\n\n"
1081 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1083 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1084 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec",
1085 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1086 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1087 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1088 Rule
winebuildDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1089 "\t$(ECHO_WINEBLD)\n"
1090 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).auto.def --def -E $(source) --filename $(module_dllname)\n\n",
1091 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
1092 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1093 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1094 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1095 "\t$(ECHO_WINEBLD)\n"
1096 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(source_path)$(SEP)$(source_name_noext).spec --filename $(module_dllname)\n"
1097 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1099 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1100 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1101 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1102 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1103 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1104 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1106 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1107 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1108 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1109 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1110 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1112 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h -s -S $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(source)\n"
1113 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1115 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1116 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1117 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1118 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1119 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1120 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1121 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1123 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h -c -C $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(source)\n"
1124 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1126 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1127 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1128 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1129 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1130 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1131 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1132 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1134 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h -p -P $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(source)\n"
1135 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1137 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1138 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1139 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1140 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1141 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1142 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1143 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1145 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1146 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1147 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1148 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1150 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1151 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1152 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1153 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1155 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1156 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1157 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1158 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1160 "\t${gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1161 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1162 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1163 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1165 "\t${host_gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1166 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1167 Rule
emptyRule ( "", NULL
);
1170 MingwModuleHandler::GenerateGccCommand (
1171 const FileLocation
* sourceFile
,
1173 const string
& extraDependencies
)
1175 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1176 string dependencies
= extraDependencies
;
1179 string extension
= GetExtension ( *sourceFile
);
1180 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1181 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1183 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1187 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1191 /* WIDL generated headers may be used */
1192 vector
<FileLocation
> rpcDependencies
;
1193 GetRpcHeaderDependencies ( rpcDependencies
);
1194 if ( rpcDependencies
.size () > 0 )
1195 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1197 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1201 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1203 const Property
* property
= module
.project
.LookupProperty(name
);
1206 return property
->value
;
1208 return string ( "" );
1211 /* caller needs to delete the returned object */
1213 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1215 string newname
= GetBasename ( base
->name
) + "_s.h";
1216 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1219 /* caller needs to delete the returned object */
1221 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1223 string newname
= GetBasename ( base
->name
) + "_c.h";
1224 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1227 /* caller needs to delete the returned object */
1229 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1231 string newname
= GetBasename ( base
->name
) + "_p.h";
1232 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1235 /* caller needs to delete the returned object */
1237 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1239 string newname
= GetBasename ( base
->name
) + ".h";
1240 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1243 /* caller needs to delete the returned object */
1245 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1247 string newname
= GetBasename ( base
->name
) + ".h";
1248 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1252 MingwModuleHandler::GenerateCommands (
1253 const CompilationUnit
& compilationUnit
,
1254 const string
& extraDependencies
)
1256 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1257 string extension
= GetExtension ( sourceFile
);
1258 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1267 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1268 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1269 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1270 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1271 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1272 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1273 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1274 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1275 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1276 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1277 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1278 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1279 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1280 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1281 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1282 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1283 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1284 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1285 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1288 Rule
*customRule
= NULL
;
1290 fprintf ( fMakefile
, "# COMMANDS\n" );
1292 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1294 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1296 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1298 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1300 customRule
= rules
[i
].rule
;
1304 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1306 GenerateGccCommand ( &sourceFile
,
1308 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1310 else if ( customRule
)
1311 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1314 throw InvalidOperationException ( __FILE__
,
1316 "Unsupported filename extension '%s' in file '%s'",
1318 backend
->GetFullName ( sourceFile
).c_str () );
1323 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1325 fprintf ( fMakefile
, "# BUILD MAP CODE\n" );
1327 fprintf ( fMakefile
,
1328 "ifeq ($(ROS_BUILDMAP),full)\n" );
1330 FileLocation
mapFilename ( OutputDirectory
,
1331 module
.output
->relative_path
,
1332 GetBasename ( module
.output
->name
) + ".map" );
1333 CLEAN_FILE ( mapFilename
);
1335 fprintf ( fMakefile
,
1336 "\t$(ECHO_OBJDUMP)\n" );
1337 fprintf ( fMakefile
,
1338 "\t$(Q)${objdump} -d -S %s > %s\n",
1339 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1340 backend
->GetFullName ( mapFilename
).c_str () );
1342 fprintf ( fMakefile
,
1344 fprintf ( fMakefile
,
1345 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1347 fprintf ( fMakefile
,
1349 fprintf ( fMakefile
,
1350 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1351 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1352 backend
->GetFullName ( mapFilename
).c_str () );
1354 fprintf ( fMakefile
,
1357 fprintf ( fMakefile
,
1362 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1364 fprintf ( fMakefile
, "# BUILD NO STRIP CODE\n" );
1366 fprintf ( fMakefile
,
1367 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1369 FileLocation
nostripFilename ( OutputDirectory
,
1370 module
.output
->relative_path
,
1371 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1372 CLEAN_FILE ( nostripFilename
);
1374 OutputCopyCommand ( *module
.output
, nostripFilename
);
1376 fprintf ( fMakefile
,
1381 MergeStringVector ( const Backend
* backend
,
1382 const vector
<FileLocation
>& input
,
1383 vector
<string
>& output
)
1387 int wrap_count
= -1;
1388 for ( size_t i
= 0; i
< input
.size (); i
++ )
1390 if ( wrap_count
++ == wrap_at
)
1392 output
.push_back ( s
);
1396 else if ( s
.size () > 0)
1398 s
+= backend
->GetFullName ( input
[i
] );
1400 if ( s
.length () > 0 )
1401 output
.push_back ( s
);
1405 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1406 vector
<FileLocation
>& objectFiles
) const
1408 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1410 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1411 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1412 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1413 objectFiles
.push_back ( *object_file
);
1419 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1421 if ( backend
->configuration
.CleanAsYouGo
)
1423 vector
<FileLocation
> objectFiles
;
1424 GetObjectsVector ( module
.non_if_data
,
1426 vector
<string
> lines
;
1427 MergeStringVector ( backend
,
1430 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1432 fprintf ( fMakefile
,
1433 "\t-@${rm} %s 2>$(NUL)\n",
1434 lines
[i
].c_str () );
1440 MingwModuleHandler::GenerateRunRsymCode () const
1442 fprintf ( fMakefile
, "# RUN RSYM CODE\n" );
1443 fprintf ( fMakefile
,
1444 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1445 fprintf ( fMakefile
,
1446 "\t$(ECHO_RSYM)\n" );
1447 fprintf ( fMakefile
,
1448 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1449 fprintf ( fMakefile
,
1454 MingwModuleHandler::GenerateRunStripCode () const
1456 fprintf ( fMakefile
, "# RUN STRIP CODE\n" );
1457 fprintf ( fMakefile
,
1458 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1459 fprintf ( fMakefile
,
1460 "\t$(ECHO_STRIP)\n" );
1461 fprintf ( fMakefile
,
1462 "\t${strip} -s -x -X $@\n\n" );
1463 fprintf ( fMakefile
,
1468 MingwModuleHandler::GenerateLinkerCommand (
1469 const string
& dependencies
,
1470 const string
& linkerParameters
,
1471 const string
& pefixupParameters
)
1473 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1474 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1475 string linker
= "${ld}";
1476 string objectsMacro
= GetObjectsMacro ( module
);
1477 string libsMacro
= GetLibsMacro ();
1479 fprintf ( fMakefile
, "# LINKER COMMAND\n" );
1481 string
target_macro ( GetTargetMacro ( module
) );
1482 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1484 string linkerScriptArgument
;
1485 if ( module
.linkerScript
!= NULL
)
1486 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1488 linkerScriptArgument
= "";
1490 /* check if we need to add default C++ libraries, ie if we have
1491 * a C++ user-mode module without the -nostdlib linker flag
1493 bool link_defaultlibs
= module
.cplusplus
&&
1494 linkerParameters
.find ("-nostdlib") == string::npos
&&
1495 !(module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
);
1497 if ( !module
.HasImportLibrary() )
1499 fprintf ( fMakefile
,
1500 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1501 target_macro
.c_str (),
1502 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1503 dependencies
.c_str (),
1504 target_folder
.c_str () );
1505 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1507 fprintf ( fMakefile
,
1508 "\t%s %s%s %s %s %s %s -o %s\n",
1510 linkerParameters
.c_str (),
1511 linkerScriptArgument
.c_str (),
1512 objectsMacro
.c_str (),
1513 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1515 GetLinkerMacro ().c_str (),
1516 target_macro
.c_str () );
1520 FileLocation
temp_exp ( IntermediateDirectory
,
1521 module
.output
->relative_path
,
1522 module
.name
+ ".exp" );
1523 CLEAN_FILE ( temp_exp
);
1525 fprintf ( fMakefile
,
1527 backend
->GetFullName ( temp_exp
).c_str (),
1528 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1529 backend
->GetFullPath ( temp_exp
).c_str () );
1530 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1532 fprintf ( fMakefile
,
1533 "\t${dlltool} --dllname %s --def %s --output-exp $@%s%s\n",
1534 module
.GetDllName ().c_str (),
1535 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1536 module
.mangledSymbols
? "" : " --kill-at",
1537 module
.underscoreSymbols
? " --add-underscore" : "" );
1539 fprintf ( fMakefile
,
1540 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1541 target_macro
.c_str (),
1542 backend
->GetFullName ( temp_exp
).c_str (),
1543 dependencies
.c_str (),
1544 target_folder
.c_str () );
1545 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1547 fprintf ( fMakefile
,
1548 "\t%s %s%s %s %s %s %s %s -o %s\n",
1551 linkerParameters
.c_str (),
1552 linkerScriptArgument
.c_str (),
1553 backend
->GetFullName ( temp_exp
).c_str (),
1554 objectsMacro
.c_str (),
1555 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1557 GetLinkerMacro ().c_str (),
1558 target_macro
.c_str () );
1560 fprintf ( fMakefile
,
1561 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1562 target_macro
.c_str (),
1563 pefixupParameters
.c_str() );
1566 GenerateBuildMapCode ();
1567 GenerateBuildNonSymbolStrippedCode ();
1568 GenerateRunRsymCode ();
1569 GenerateRunStripCode ();
1570 GenerateCleanObjectsAsYouGoCode ();
1572 if ( definitionFilename
)
1573 delete definitionFilename
;
1578 MingwModuleHandler::GeneratePhonyTarget() const
1580 string
targetMacro ( GetTargetMacro ( module
) );
1581 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1583 fprintf ( fMakefile
, "# PHONY TARGET\n" );
1584 fprintf ( fMakefile
,
1586 targetMacro
.c_str ());
1587 fprintf ( fMakefile
, "%s: | %s\n",
1588 targetMacro
.c_str (),
1589 backend
->GetFullPath ( *target_file
).c_str () );
1595 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1598 string moduleDependencies
;
1600 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1602 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1603 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1605 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1606 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1607 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1608 if ( GetExtension ( *objectFilename
) == ".h" )
1609 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1610 else if ( GetExtension ( *objectFilename
) == ".rc" )
1611 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1612 delete objectFilename
;
1615 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1617 GenerateCommands ( *compilationUnits
[i
],
1618 moduleDependencies
);
1619 fprintf ( fMakefile
,
1623 vector
<CompilationUnit
*> sourceCompilationUnits
;
1624 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1625 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1627 GenerateCommands ( *sourceCompilationUnits
[i
],
1628 moduleDependencies
);
1630 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1632 SpecFileType spec
= IsSpecDefinitionFile ();
1639 defRule
= &winebuildPRule
;
1641 defRule
= &winebuildRule
;
1643 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
1648 MingwModuleHandler::GenerateObjectFileTargets ()
1650 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1652 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1656 string cc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gcc}" : "${gcc}" );
1657 string cppc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gpp}" : "${gpp}" );
1659 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1660 CLEAN_FILE ( *pchFilename
);
1661 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1662 /* WIDL generated headers may be used */
1663 vector
<FileLocation
> rpcDependencies
;
1664 GetRpcHeaderDependencies ( rpcDependencies
);
1665 if ( rpcDependencies
.size () > 0 )
1666 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1667 fprintf ( fMakefile
,
1669 backend
->GetFullName ( *pchFilename
).c_str(),
1670 dependencies
.c_str(),
1671 backend
->GetFullPath ( *pchFilename
).c_str() );
1672 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1673 fprintf ( fMakefile
,
1674 "\t%s -o %s %s %s -gstabs+ %s\n\n",
1675 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1676 backend
->GetFullName ( *pchFilename
).c_str(),
1677 module
.cplusplus
? cxxflagsMacro
.c_str() : cflagsMacro
.c_str(),
1678 GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, module
.cplusplus
? CompilerTypeCPP
: CompilerTypeCC
).c_str(),
1679 backend
->GetFullName ( baseHeaderFile
).c_str() );
1683 GenerateObjectFileTargets ( module
.non_if_data
);
1684 fprintf ( fMakefile
, "\n" );
1687 /* caller needs to delete the returned object */
1689 MingwModuleHandler::GenerateArchiveTarget ()
1691 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1692 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1694 fprintf ( fMakefile
, "# ARCHIVE TARGET\n" );
1696 if ( IsStaticLibrary ( module
) && definitionFilename
)
1698 arRule1
.Execute ( fMakefile
,
1703 backend
->GetFullName ( *definitionFilename
).c_str () );
1705 fprintf ( fMakefile
,
1706 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1707 module
.GetDllName ().c_str (),
1708 backend
->GetFullName ( *definitionFilename
).c_str (),
1709 module
.mangledSymbols
? "" : " --kill-at",
1710 module
.underscoreSymbols
? " --add-underscore" : "" );
1713 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1715 if ( definitionFilename
)
1716 delete definitionFilename
;
1718 if(module
.type
== HostStaticLibrary
)
1719 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1721 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1723 GenerateCleanObjectsAsYouGoCode ();
1725 fprintf ( fMakefile
, "\n" );
1727 return archiveFilename
;
1731 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1733 return ssprintf ( "$(%s_OBJS)",
1734 module
.name
.c_str () );
1738 MingwModuleHandler::GetLinkingDependenciesMacro () const
1740 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1744 MingwModuleHandler::GetLibsMacro () const
1746 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1750 MingwModuleHandler::GetLinkerMacro () const
1752 return ssprintf ( "$(%s_LFLAGS)",
1753 module
.name
.c_str () );
1757 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1759 if ( ReferenceObjects ( module
) )
1760 return GetObjectsMacro ( module
);
1763 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1764 string target
= backend
->GetFullName ( *target_file
).c_str ();
1771 MingwModuleHandler::GenerateSourceMacro ()
1773 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1775 GenerateSourceMacros ( module
.non_if_data
);
1777 // future references to the macro will be to get its values
1778 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1782 MingwModuleHandler::GenerateObjectMacro ()
1784 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1786 GenerateObjectMacros ( module
.non_if_data
);
1788 // future references to the macro will be to get its values
1789 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1793 MingwModuleHandler::GenerateTargetMacro ()
1795 fprintf ( fMakefile
, "# TARGET MACRO\n" );
1796 fprintf ( fMakefile
,
1798 GetTargetMacro ( module
, false ).c_str (),
1799 GetModuleTargets ( module
).c_str () );
1803 MingwModuleHandler::GetRpcHeaderDependencies (
1804 vector
<FileLocation
>& dependencies
) const
1806 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1808 Library
& library
= *module
.non_if_data
.libraries
[i
];
1809 if ( library
.importedModule
->type
== RpcServer
||
1810 library
.importedModule
->type
== RpcClient
||
1811 library
.importedModule
->type
== RpcProxy
||
1812 library
.importedModule
->type
== IdlHeader
)
1814 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1816 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1817 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1818 string extension
= GetExtension ( sourceFile
);
1819 if ( extension
== ".idl" || extension
== ".IDL" )
1821 string basename
= GetBasename ( sourceFile
.name
);
1822 if ( library
.importedModule
->type
== RpcServer
)
1824 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1825 dependencies
.push_back ( *header
);
1828 if ( library
.importedModule
->type
== RpcClient
)
1830 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1831 dependencies
.push_back ( *header
);
1834 if ( library
.importedModule
->type
== RpcProxy
)
1836 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1837 dependencies
.push_back ( *header
);
1840 if ( library
.importedModule
->type
== IdlHeader
)
1842 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1843 dependencies
.push_back ( *header
);
1853 MingwModuleHandler::GenerateOtherMacros ()
1855 set
<const Define
*> used_defs
;
1857 fprintf ( fMakefile
, "# OTHER MACROS\n" );
1859 commonflagsMacro
= ssprintf ("%s_COMMONFLAGS", module
.name
.c_str ());
1860 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1861 cxxflagsMacro
= ssprintf ("%s_CXXFLAGS", module
.name
.c_str ());
1862 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1863 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1864 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1865 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1866 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1867 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1872 &module
.linkerFlags
,
1875 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1877 GenerateMacros("+=", module
.project
.host_non_if_data
, NULL
, used_defs
);
1883 module
.project
.non_if_data
,
1888 if ( IsSpecDefinitionFile() )
1890 vector
<FileLocation
> s
;
1891 GetSpecImplibDependencies ( s
, module
.importLibrary
->source
);
1896 linkDepsMacro
.c_str() );
1897 for ( size_t i
= 0; i
< s
.size(); i
++ )
1898 fprintf ( fMakefile
,
1900 backend
->GetFullName ( s
[i
] ).c_str () );
1901 fprintf ( fMakefile
, "\n" );
1904 string globalCflags
= " ";
1905 globalCflags
+= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
1906 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1908 if ( module
.dynamicCRT
)
1909 globalCflags
+= " -D_DLL -D__USE_CRTIMP";
1912 globalCflags
+= " -Wall -Wpointer-arith";
1913 globalCflags
+= " -gstabs+";
1914 if ( backend
->usePipe
)
1915 globalCflags
+= " -pipe";
1916 if ( !module
.allowWarnings
)
1917 globalCflags
+= " -Werror";
1918 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1920 if ( module
.cplusplus
)
1921 globalCflags
+= " $(HOST_CPPFLAGS)";
1923 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
1927 if ( module
.cplusplus
)
1929 globalCflags
+= " $(TARGET_CPPFLAGS)";
1932 globalCflags
+= " -nostdinc";
1935 // Always force disabling of sibling calls optimisation for GCC
1936 // (TODO: Move to version-specific once this bug is fixed in GCC)
1937 globalCflags
+= " -fno-optimize-sibling-calls";
1939 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1944 cflagsMacro
.c_str (),
1945 (" $(PROJECT_CFLAGS)" + globalCflags
).c_str () );
1950 cxxflagsMacro
.c_str (),
1951 (" $(PROJECT_CXXFLAGS)" + globalCflags
).c_str () );
1955 "%s += $(PROJECT_RCFLAGS)\n",
1956 windresflagsMacro
.c_str () );
1960 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
1961 widlflagsMacro
.c_str (),
1962 module
.output
->relative_path
.c_str () );
1966 "%s_LFLAGS := $(PROJECT_LFLAGS) $(%s_LFLAGS)\n",
1967 module
.name
.c_str (),
1968 module
.name
.c_str () );
1975 cflagsMacro
.c_str (),
1976 globalCflags
.c_str () );
1981 cxxflagsMacro
.c_str (),
1982 globalCflags
.c_str () );
1986 "%s_LFLAGS += $(HOST_LFLAGS)\n",
1987 module
.name
.c_str () );
1993 linkDepsMacro
.c_str (),
1994 libsMacro
.c_str () );
1996 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
1997 if ( strlen( cflags
) > 0 )
1999 fprintf ( fMakefile
,
2001 cflagsMacro
.c_str (),
2003 fprintf ( fMakefile
,
2005 cxxflagsMacro
.c_str (),
2009 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
2010 if ( strlen( nasmflags
) > 0 )
2012 fprintf ( fMakefile
,
2014 nasmflagsMacro
.c_str (),
2018 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
2019 if ( strlen( linkerflags
) > 0 )
2021 fprintf ( fMakefile
,
2023 linkerflagsMacro
.c_str (),
2027 fprintf ( fMakefile
, "\n\n" );
2029 // future references to the macros will be to get their values
2030 commonflagsMacro
= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
2031 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2032 cxxflagsMacro
= ssprintf ("$(%s)", cxxflagsMacro
.c_str ());
2033 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2034 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2038 MingwModuleHandler::GenerateRules ()
2042 fprintf ( fMakefile
, "# RULES\n" );
2043 string targetMacro
= GetTargetMacro ( module
);
2044 //CLEAN_FILE ( targetMacro );
2045 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2047 // generate phony target for module name
2048 fprintf ( fMakefile
, ".PHONY: %s\n",
2049 module
.name
.c_str () );
2050 string dependencies
= GetTargetMacro ( module
);
2051 if ( module
.type
== Test
)
2052 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2053 fprintf ( fMakefile
, "%s: %s\n\n",
2054 module
.name
.c_str (),
2055 dependencies
.c_str () );
2056 if ( module
.type
== Test
)
2058 fprintf ( fMakefile
,
2060 targetMacro
.c_str ());
2063 if ( !ReferenceObjects ( module
) )
2065 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2070 spec
= IsSpecDefinitionFile();
2077 defRule
= &winebuildPDefRule
;
2079 defRule
= &winebuildDefRule
;
2081 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
2084 GenerateObjectFileTargets ();
2088 MingwModuleHandler::GetInvocationDependencies (
2089 const Module
& module
,
2090 string_list
& dependencies
)
2092 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2094 Invoke
& invoke
= *module
.invocations
[i
];
2095 if ( invoke
.invokeModule
== &module
)
2096 /* Protect against circular dependencies */
2098 invoke
.GetTargets ( dependencies
);
2103 MingwModuleHandler::GenerateInvocations () const
2105 if ( module
.invocations
.size () == 0 )
2108 fprintf ( fMakefile
, "# INVOCATIONS\n" );
2110 size_t iend
= module
.invocations
.size ();
2111 for ( size_t i
= 0; i
< iend
; i
++ )
2113 const Invoke
& invoke
= *module
.invocations
[i
];
2115 if ( invoke
.invokeModule
->type
!= BuildTool
)
2117 throw XMLInvalidBuildFileException (
2118 module
.node
.location
,
2119 "Only modules of type buildtool can be invoked." );
2122 string invokeTarget
= module
.GetInvocationTarget ( i
);
2123 string_list invoke_targets
;
2124 assert ( invoke_targets
.size() );
2125 invoke
.GetTargets ( invoke_targets
);
2126 fprintf ( fMakefile
,
2128 invokeTarget
.c_str () );
2129 fprintf ( fMakefile
,
2131 invokeTarget
.c_str () );
2132 size_t j
, jend
= invoke_targets
.size();
2133 for ( j
= 0; j
< jend
; j
++ )
2135 fprintf ( fMakefile
,
2137 invoke_targets
[i
].c_str () );
2139 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2140 for ( j
= 1; j
< jend
; j
++ )
2141 fprintf ( fMakefile
,
2143 invoke_targets
[i
].c_str () );
2144 fprintf ( fMakefile
,
2146 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2147 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2148 fprintf ( fMakefile
,
2150 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2151 invoke
.GetParameters ().c_str () );
2156 MingwModuleHandler::GetPreconditionDependenciesName () const
2158 return module
.name
+ "_precondition";
2162 MingwModuleHandler::GetDefaultDependencies (
2163 string_list
& dependencies
) const
2165 /* Avoid circular dependency */
2166 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2169 if (module
.name
!= "psdk" &&
2170 module
.name
!= "dxsdk")
2172 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2173 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2176 if (module
.name
!= "errcodes" &&
2177 module
.name
!= "bugcodes" &&
2178 module
.name
!= "ntstatus")
2180 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2181 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2182 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2185 ///* Check if any dependent library relies on the generated headers */
2186 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2188 // const Module& m = *module.project.modules[i];
2189 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2191 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2192 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2193 // string extension = GetExtension ( sourceFile );
2194 // if (extension == ".mc" || extension == ".MC" )
2196 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2197 // dependencies.push_back ( dependency );
2204 MingwModuleHandler::GeneratePreconditionDependencies ()
2206 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
2207 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2208 string_list dependencies
;
2209 GetDefaultDependencies ( dependencies
);
2210 GetModuleDependencies ( dependencies
);
2212 GetInvocationDependencies ( module
, dependencies
);
2214 if ( dependencies
.size() )
2216 fprintf ( fMakefile
,
2218 preconditionDependenciesName
.c_str () );
2219 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2220 fprintf ( fMakefile
,
2222 dependencies
[i
].c_str () );
2223 fprintf ( fMakefile
, "\n\n" );
2226 fprintf ( fMakefile
, "\n" );
2230 MingwModuleHandler::IsSpecDefinitionFile () const
2232 if(!module
.importLibrary
)
2235 std::string ext
= GetExtension ( *module
.importLibrary
->source
);
2237 if ( ext
== ".spec" )
2240 if ( ext
== ".pspec" )
2246 /* caller needs to delete the returned object */
2248 MingwModuleHandler::GetDefinitionFilename () const
2250 if ( module
.importLibrary
== NULL
)
2253 if ( IsSpecDefinitionFile () )
2255 return new FileLocation ( IntermediateDirectory
,
2256 module
.importLibrary
->source
->relative_path
,
2257 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2261 return new FileLocation ( SourceDirectory
,
2262 module
.importLibrary
->source
->relative_path
,
2263 module
.importLibrary
->source
->name
);
2268 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2270 if ( module
.importLibrary
!= NULL
)
2272 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2273 const FileLocation
*defFilename
= GetDefinitionFilename ();
2274 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2276 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE\n" );
2278 fprintf ( fMakefile
, "%s:",
2279 backend
->GetFullName ( *library_target
).c_str () );
2283 fprintf ( fMakefile
, " %s",
2284 backend
->GetFullName ( *defFilename
).c_str () );
2287 fprintf ( fMakefile
, " | %s\n",
2288 backend
->GetFullPath ( *library_target
).c_str () );
2290 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2292 fprintf ( fMakefile
,
2293 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2294 module
.GetDllName ().c_str (),
2295 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2297 backend
->GetFullName ( *library_target
).c_str (),
2298 module
.mangledSymbols
? "" : " --kill-at",
2299 module
.underscoreSymbols
? " --add-underscore" : "" );
2303 delete library_target
;
2308 MingwModuleHandler::GetSpecObjectDependencies (
2309 vector
<FileLocation
>& dependencies
,
2310 const FileLocation
*file
) const
2312 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2313 file
->relative_path
,
2314 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2318 MingwModuleHandler::GetSpecImplibDependencies (
2319 vector
<FileLocation
>& dependencies
,
2320 const FileLocation
*file
) const
2322 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2323 file
->relative_path
,
2324 GetBasename ( file
->name
) + "_" + module
.name
+ ".auto.def" ) );
2328 MingwModuleHandler::GetMcObjectDependencies (
2329 vector
<FileLocation
>& dependencies
,
2330 const FileLocation
*file
) const
2332 string basename
= GetBasename ( file
->name
);
2334 FileLocation
defDependency ( IntermediateDirectory
,
2337 dependencies
.push_back ( defDependency
);
2339 FileLocation
stubsDependency ( IntermediateDirectory
,
2340 file
->relative_path
,
2342 dependencies
.push_back ( stubsDependency
);
2346 MingwModuleHandler::GetWidlObjectDependencies (
2347 vector
<FileLocation
>& dependencies
,
2348 const FileLocation
*file
) const
2350 string basename
= GetBasename ( file
->name
);
2351 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2353 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2354 file
->relative_path
,
2355 basename
+ "_s.c" );
2356 dependencies
.push_back ( serverSourceDependency
);
2357 dependencies
.push_back ( *generatedHeaderFilename
);
2359 delete generatedHeaderFilename
;
2363 MingwModuleHandler::GetDefinitionDependencies (
2364 vector
<FileLocation
>& dependencies
) const
2366 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2367 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2369 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2370 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2371 string extension
= GetExtension ( sourceFile
);
2373 if (extension
== ".spec" || extension
== ".pspec")
2374 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2376 if (extension
== ".idl")
2378 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2379 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2384 enum DebugSupportType
2391 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2397 case DebugKernelMode
:
2398 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2402 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2409 module
.non_if_data
.libraries
.push_back(pLibrary
);
2413 MingwAddCRTLibrary( Module
&module
)
2415 const char * crtAttr
= module
.CRT
.c_str ();
2416 const char * crtLib
= NULL
;
2418 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2420 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2422 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2423 crtLib
= "libcntpr";
2424 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2429 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2431 if ( pLibrary
->importedModule
== NULL
)
2433 throw XMLInvalidBuildFileException (
2434 module
.node
.location
,
2435 "module '%s' trying to import non-existant C runtime module '%s'",
2436 module
.name
.c_str(),
2440 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2444 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2445 : MingwModuleHandler ( module_
)
2450 MingwBuildToolModuleHandler::Process ()
2452 GenerateBuildToolModuleTarget ();
2456 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2458 string
targetMacro ( GetTargetMacro (module
) );
2459 string objectsMacro
= GetObjectsMacro ( module
);
2460 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2461 string libsMacro
= GetLibsMacro ();
2465 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2468 if ( module
.cplusplus
)
2469 linker
= "${host_gpp}";
2471 linker
= "${host_gcc}";
2473 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2474 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2475 targetMacro
.c_str (),
2476 objectsMacro
.c_str (),
2477 linkDepsMacro
.c_str (),
2478 backend
->GetFullPath ( *target_file
).c_str () );
2479 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2480 fprintf ( fMakefile
,
2481 "\t%s %s -o $@ %s %s\n\n",
2483 GetLinkerMacro ().c_str (),
2484 objectsMacro
.c_str (),
2485 libsMacro
.c_str () );
2491 MingwKernelModuleHandler::MingwKernelModuleHandler (
2492 const Module
& module_
)
2494 : MingwModuleHandler ( module_
)
2499 MingwKernelModuleHandler::Process ()
2501 GenerateKernelModuleTarget ();
2505 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2507 string
targetMacro ( GetTargetMacro ( module
) );
2508 string workingDirectory
= GetWorkingDirectory ( );
2509 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2511 GenerateImportLibraryTargetIfNeeded ();
2513 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2517 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2519 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2520 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2521 module
.baseaddress
.c_str () );
2523 GenerateLinkerCommand ( dependencies
,
2524 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2529 GeneratePhonyTarget();
2534 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2535 const Module
& module_
)
2537 : MingwModuleHandler ( module_
)
2543 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2545 MingwAddCRTLibrary ( module
);
2546 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2550 MingwKernelModeDLLModuleHandler::Process ()
2552 GenerateKernelModeDLLModuleTarget ();
2556 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2558 string
targetMacro ( GetTargetMacro ( module
) );
2559 string workingDirectory
= GetWorkingDirectory ();
2560 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2562 GenerateImportLibraryTargetIfNeeded ();
2564 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2568 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2570 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2571 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2572 module
.baseaddress
.c_str () );
2573 GenerateLinkerCommand ( dependencies
,
2579 GeneratePhonyTarget();
2584 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2585 const Module
& module_
)
2587 : MingwModuleHandler ( module_
)
2592 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2594 MingwAddCRTLibrary ( module
);
2595 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2599 MingwNativeDLLModuleHandler::Process ()
2601 GenerateNativeDLLModuleTarget ();
2605 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2607 string
targetMacro ( GetTargetMacro (module
) );
2608 string workingDirectory
= GetWorkingDirectory ( );
2609 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2611 GenerateImportLibraryTargetIfNeeded ();
2613 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2617 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2619 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2620 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2621 module
.baseaddress
.c_str () );
2622 GenerateLinkerCommand ( dependencies
,
2628 GeneratePhonyTarget();
2633 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2634 const Module
& module_
)
2636 : MingwModuleHandler ( module_
)
2641 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2643 MingwAddCRTLibrary ( module
);
2644 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2648 MingwNativeCUIModuleHandler::Process ()
2650 GenerateNativeCUIModuleTarget ();
2654 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2656 string
targetMacro ( GetTargetMacro (module
) );
2657 string workingDirectory
= GetWorkingDirectory ( );
2658 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2660 GenerateImportLibraryTargetIfNeeded ();
2662 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2666 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2668 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2669 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2670 module
.baseaddress
.c_str () );
2671 GenerateLinkerCommand ( dependencies
,
2677 GeneratePhonyTarget();
2682 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2683 const Module
& module_
)
2685 : MingwModuleHandler ( module_
)
2689 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2690 const Module
& module_
)
2692 : MingwModuleHandler ( module_
)
2697 MingwAddImplicitLibraries( Module
&module
)
2701 if ( module
.type
!= Win32DLL
2702 && module
.type
!= Win32OCX
2703 && module
.type
!= Win32CUI
2704 && module
.type
!= Win32GUI
2705 && module
.type
!= Win32SCR
)
2710 if ( module
.isDefaultEntryPoint
)
2712 if ( module
.IsDLL () )
2714 //pLibrary = new Library ( module, "__mingw_dllmain" );
2715 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2719 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2720 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2724 pLibrary
= new Library ( module
, "mingw_common" );
2725 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2727 MingwAddCRTLibrary ( module
);
2728 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2732 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2734 MingwAddImplicitLibraries ( module
);
2738 MingwWin32DLLModuleHandler::Process ()
2740 GenerateWin32DLLModuleTarget ();
2744 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2746 string
targetMacro ( GetTargetMacro (module
) );
2747 string workingDirectory
= GetWorkingDirectory ( );
2748 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2750 GenerateImportLibraryTargetIfNeeded ();
2752 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2756 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2758 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2759 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2760 module
.baseaddress
.c_str () );
2761 GenerateLinkerCommand ( dependencies
,
2767 GeneratePhonyTarget();
2773 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2775 MingwAddImplicitLibraries ( module
);
2779 MingwWin32OCXModuleHandler::Process ()
2781 GenerateWin32OCXModuleTarget ();
2785 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2787 string
targetMacro ( GetTargetMacro (module
) );
2788 string workingDirectory
= GetWorkingDirectory ( );
2789 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2791 GenerateImportLibraryTargetIfNeeded ();
2793 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2797 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2799 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2800 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2801 module
.baseaddress
.c_str () );
2802 GenerateLinkerCommand ( dependencies
,
2808 GeneratePhonyTarget();
2813 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2814 const Module
& module_
)
2816 : MingwModuleHandler ( module_
)
2821 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2823 MingwAddImplicitLibraries ( module
);
2827 MingwWin32CUIModuleHandler::Process ()
2829 GenerateWin32CUIModuleTarget ();
2833 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2835 string
targetMacro ( GetTargetMacro (module
) );
2836 string workingDirectory
= GetWorkingDirectory ( );
2837 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2839 GenerateImportLibraryTargetIfNeeded ();
2841 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2845 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2847 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2848 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2849 module
.baseaddress
.c_str () );
2850 GenerateLinkerCommand ( dependencies
,
2856 GeneratePhonyTarget();
2861 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2862 const Module
& module_
)
2864 : MingwModuleHandler ( module_
)
2869 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2871 MingwAddImplicitLibraries ( module
);
2875 MingwWin32GUIModuleHandler::Process ()
2877 GenerateWin32GUIModuleTarget ();
2881 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2883 string
targetMacro ( GetTargetMacro (module
) );
2884 string workingDirectory
= GetWorkingDirectory ( );
2885 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2887 GenerateImportLibraryTargetIfNeeded ();
2889 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2893 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2895 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2896 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2897 module
.baseaddress
.c_str () );
2898 GenerateLinkerCommand ( dependencies
,
2904 GeneratePhonyTarget();
2909 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2910 const Module
& module_
)
2912 : MingwModuleHandler ( module_
)
2917 MingwBootLoaderModuleHandler::Process ()
2919 GenerateBootLoaderModuleTarget ();
2923 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2925 string
targetName ( module
.output
->name
);
2926 string
targetMacro ( GetTargetMacro (module
) );
2927 string workingDirectory
= GetWorkingDirectory ();
2928 FileLocation
junk_tmp ( TemporaryDirectory
,
2930 module
.name
+ ".junk.tmp" );
2931 CLEAN_FILE ( junk_tmp
);
2932 string objectsMacro
= GetObjectsMacro ( module
);
2933 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2937 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2939 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2940 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2941 targetMacro
.c_str (),
2942 objectsMacro
.c_str (),
2943 linkDepsMacro
.c_str (),
2944 backend
->GetFullPath ( *target_file
).c_str () );
2946 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2948 if (Environment::GetArch() == "arm")
2950 fprintf ( fMakefile
,
2951 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
2952 backend
->GetFullName ( junk_tmp
).c_str (),
2953 objectsMacro
.c_str (),
2954 linkDepsMacro
.c_str (),
2955 GetLinkerMacro ().c_str ());
2959 fprintf ( fMakefile
,
2960 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
2961 backend
->GetFullName ( junk_tmp
).c_str (),
2962 objectsMacro
.c_str (),
2963 linkDepsMacro
.c_str (),
2964 GetLinkerMacro ().c_str ());
2966 fprintf ( fMakefile
,
2967 "\t${objcopy} -O binary %s $@\n",
2968 backend
->GetFullName ( junk_tmp
).c_str () );
2969 GenerateBuildMapCode ( &junk_tmp
);
2970 fprintf ( fMakefile
,
2971 "\t-@${rm} %s 2>$(NUL)\n",
2972 backend
->GetFullName ( junk_tmp
).c_str () );
2978 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2979 const Module
& module_
)
2980 : MingwModuleHandler ( module_
)
2985 MingwBootProgramModuleHandler::Process ()
2987 GenerateBootProgramModuleTarget ();
2991 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2993 string
targetName ( module
.output
->name
);
2994 string
targetMacro ( GetTargetMacro (module
) );
2995 string workingDirectory
= GetWorkingDirectory ();
2996 FileLocation
junk_tmp ( TemporaryDirectory
,
2998 module
.name
+ ".junk.tmp" );
2999 FileLocation
junk_elf ( TemporaryDirectory
,
3001 module
.name
+ ".junk.elf" );
3002 FileLocation
junk_cpy ( TemporaryDirectory
,
3004 module
.name
+ ".junk.elf" );
3005 CLEAN_FILE ( junk_tmp
);
3006 CLEAN_FILE ( junk_elf
);
3007 CLEAN_FILE ( junk_cpy
);
3008 string objectsMacro
= GetObjectsMacro ( module
);
3009 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3010 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3014 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
3016 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3017 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3018 targetMacro
.c_str (),
3019 objectsMacro
.c_str (),
3020 linkDepsMacro
.c_str (),
3021 payload
->name
.c_str (),
3022 backend
->GetFullPath ( *target_file
).c_str () );
3024 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3026 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3027 module
.buildtype
.c_str (),
3028 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3029 backend
->GetFullName ( junk_cpy
).c_str () );
3031 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3032 module
.buildtype
.c_str (),
3033 backend
->GetFullName ( junk_cpy
).c_str (),
3034 backend
->GetFullName ( junk_tmp
).c_str () );
3036 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
3037 module
.buildtype
.c_str (),
3038 linkDepsMacro
.c_str (),
3039 backend
->GetFullName ( junk_tmp
).c_str (),
3040 backend
->GetFullName ( junk_elf
).c_str () );
3042 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3043 module
.buildtype
.c_str (),
3044 backend
->GetFullName ( junk_elf
).c_str (),
3045 backend
->GetFullName ( *module
.output
) .c_str () );
3047 fprintf ( fMakefile
,
3048 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3049 backend
->GetFullName ( junk_tmp
).c_str (),
3050 backend
->GetFullName ( junk_elf
).c_str (),
3051 backend
->GetFullName ( junk_cpy
).c_str () );
3057 MingwIsoModuleHandler::MingwIsoModuleHandler (
3058 const Module
& module_
)
3060 : MingwModuleHandler ( module_
)
3065 MingwIsoModuleHandler::Process ()
3067 GenerateIsoModuleTarget ();
3071 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3072 const string
& bootcdDirectory
)
3074 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3076 const Module
& m
= *p
->second
;
3079 if ( m
.bootstrap
!= NULL
)
3081 FileLocation
targetFile ( OutputDirectory
,
3082 m
.bootstrap
->base
.length () > 0
3083 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3085 m
.bootstrap
->nameoncd
);
3086 OutputCopyCommand ( *m
.output
, targetFile
);
3092 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3093 const string
& bootcdDirectory
)
3095 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3097 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3098 FileLocation
targetFile ( OutputDirectory
,
3099 cdfile
.target
->relative_path
.length () > 0
3100 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3102 cdfile
.target
->name
);
3103 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3108 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3109 const string
& bootcdDirectory
)
3111 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3113 const Module
& m
= *p
->second
;
3116 if ( m
.bootstrap
!= NULL
)
3118 FileLocation
targetDirectory ( OutputDirectory
,
3119 m
.bootstrap
->base
.length () > 0
3120 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3123 out
.push_back ( targetDirectory
);
3129 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3130 const string
& bootcdDirectory
)
3132 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3134 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3135 FileLocation
targetDirectory ( OutputDirectory
,
3136 cdfile
.target
->relative_path
.length () > 0
3137 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3140 out
.push_back( targetDirectory
);
3145 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3146 const string
& bootcdDirectory
)
3148 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3149 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3153 MingwIsoModuleHandler::GetBootstrapCdFiles (
3154 vector
<FileLocation
>& out
) const
3156 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3158 const Module
& m
= *p
->second
;
3161 if ( m
.bootstrap
!= NULL
)
3163 out
.push_back ( *m
.output
);
3169 MingwIsoModuleHandler::GetNonModuleCdFiles (
3170 vector
<FileLocation
>& out
) const
3172 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3174 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3175 out
.push_back ( *cdfile
.source
);
3180 MingwIsoModuleHandler::GetCdFiles (
3181 vector
<FileLocation
>& out
) const
3183 GetBootstrapCdFiles ( out
);
3184 GetNonModuleCdFiles ( out
);
3188 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3190 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
3191 string bootcdDirectory
= "cd";
3192 FileLocation
bootcd ( OutputDirectory
,
3195 FileLocation
bootcdReactos ( OutputDirectory
,
3196 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3198 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3199 vector
<FileLocation
> vCdDirectories
;
3202 FileLocation
srcunattend ( SourceDirectory
,
3203 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3205 FileLocation
tarunattend ( bootcdReactos
.directory
,
3206 bootcdReactos
.relative_path
,
3208 if (module
.type
== IsoRegTest
)
3209 vSourceFiles
.push_back ( srcunattend
);
3212 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3216 throw InvalidOperationException ( module
.node
.location
.c_str(),
3218 "Invalid bootsector. module '%s' requires <bootsector>",
3219 module
.name
.c_str ());
3222 const FileLocation
*isoboot
= bootModule
->output
;
3223 vSourceFiles
.push_back ( *isoboot
);
3225 // prepare reactos.dff and reactos.inf
3226 FileLocation
reactosDff ( SourceDirectory
,
3227 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3229 FileLocation
reactosInf ( bootcdReactos
.directory
,
3230 bootcdReactos
.relative_path
,
3233 vSourceFiles
.push_back ( reactosDff
);
3236 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3237 Iso/LiveIso outputs are generated in code base root
3239 string IsoName
= module
.output
->name
;
3241 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3244 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3245 GetCdFiles ( vCdFiles
);
3246 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3247 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3249 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3250 module
.name
.c_str ());
3251 fprintf ( fMakefile
,
3252 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3253 module
.name
.c_str (),
3254 backend
->GetFullName ( *isoboot
).c_str (),
3255 sourceFiles
.c_str (),
3257 cdDirectories
.c_str () );
3258 fprintf ( fMakefile
,
3259 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3260 backend
->GetFullName ( reactosDff
).c_str (),
3261 backend
->GetFullPath ( bootcdReactos
).c_str () );
3262 fprintf ( fMakefile
,
3263 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3264 backend
->GetFullName ( reactosDff
).c_str (),
3265 backend
->GetFullName ( reactosInf
).c_str (),
3266 backend
->GetFullPath ( bootcdReactos
).c_str ());
3267 fprintf ( fMakefile
,
3268 "\t-@${rm} %s 2>$(NUL)\n",
3269 backend
->GetFullName ( reactosInf
).c_str () );
3270 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3271 OutputCdfileCopyCommands ( bootcdDirectory
);
3273 if (module
.type
== IsoRegTest
)
3274 OutputCopyCommand ( srcunattend
, tarunattend
);
3276 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3277 fprintf ( fMakefile
,
3278 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3279 backend
->GetFullName ( *isoboot
).c_str (),
3280 backend
->GetFullPath ( bootcd
).c_str (),
3282 fprintf ( fMakefile
,
3287 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3288 const Module
& module_
)
3290 : MingwModuleHandler ( module_
)
3295 MingwLiveIsoModuleHandler::Process ()
3297 GenerateLiveIsoModuleTarget ();
3301 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3303 FileLocation
dir ( OutputDirectory
,
3306 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3310 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3311 string
& reactosDirectory
)
3313 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3315 const Module
& m
= *p
->second
;
3320 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3321 FileLocation
destination ( OutputDirectory
,
3322 m
.install
->relative_path
.length () > 0
3323 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3324 : livecdDirectory
+ sSep
+ reactosDirectory
,
3326 OutputCopyCommand ( *aliasedModule
.output
,
3333 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3334 string
& reactosDirectory
)
3336 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3338 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3339 FileLocation
target ( OutputDirectory
,
3340 installfile
.target
->relative_path
.length () > 0
3341 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3342 : livecdDirectory
+ sSep
+ reactosDirectory
,
3343 installfile
.target
->name
);
3344 OutputCopyCommand ( *installfile
.source
, target
);
3349 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3351 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3352 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3353 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3354 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3355 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3356 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3358 FileLocation
livecdIni ( SourceDirectory
,
3359 "boot" + sSep
+ "bootdata",
3361 FileLocation
destination ( OutputDirectory
,
3364 OutputCopyCommand ( livecdIni
,
3369 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3371 FileLocation
freeldr ( OutputDirectory
,
3372 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3374 FileLocation
destination ( OutputDirectory
,
3375 livecdDirectory
+ sSep
+ "loader",
3377 OutputCopyCommand ( freeldr
,
3382 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3384 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
3385 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3386 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3388 fprintf ( fMakefile
,
3389 "\t$(ECHO_MKHIVE)\n" );
3390 fprintf ( fMakefile
,
3391 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3392 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3393 cSep
, cSep
, cSep
, cSep
);
3397 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3399 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3400 string livecdDirectory
= module
.name
;
3401 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3406 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3410 throw InvalidOperationException ( module
.node
.location
.c_str(),
3412 "Invalid bootsector. module '%s' requires <bootsector>",
3413 module
.name
.c_str ());
3416 const FileLocation
*isoboot
= bootModule
->output
;
3419 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3420 Iso/LiveIso outputs are generated in code base root
3422 IsoName
= module
.output
->name
;
3424 string reactosDirectory
= "reactos";
3425 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3426 FileLocation
livecdReactos ( OutputDirectory
,
3427 livecdReactosNoFixup
,
3429 CLEAN_FILE ( livecdReactos
);
3431 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3432 module
.name
.c_str ());
3433 fprintf ( fMakefile
,
3434 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3435 module
.name
.c_str (),
3436 backend
->GetFullName ( *isoboot
) .c_str (),
3437 backend
->GetFullPath ( livecdReactos
).c_str () );
3438 OutputModuleCopyCommands ( livecdDirectory
,
3440 OutputNonModuleCopyCommands ( livecdDirectory
,
3442 OutputProfilesDirectoryCommands ( livecdDirectory
);
3443 OutputLoaderCommands ( livecdDirectory
);
3444 OutputRegistryCommands ( livecdDirectory
);
3445 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3446 fprintf ( fMakefile
,
3447 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3448 backend
->GetFullName( *isoboot
).c_str (),
3449 backend
->GetFullPath ( livecd
).c_str (),
3451 fprintf ( fMakefile
,
3456 MingwTestModuleHandler::MingwTestModuleHandler (
3457 const Module
& module_
)
3459 : MingwModuleHandler ( module_
)
3464 MingwTestModuleHandler::Process ()
3466 GenerateTestModuleTarget ();
3469 /* caller needs to delete the returned object */
3471 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3473 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3474 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3475 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3479 MingwTestModuleHandler::GenerateTestModuleTarget ()
3481 string
targetMacro ( GetTargetMacro ( module
) );
3482 string workingDirectory
= GetWorkingDirectory ( );
3483 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3485 GenerateImportLibraryTargetIfNeeded ();
3487 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3491 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3493 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3494 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3495 module
.baseaddress
.c_str () );
3496 GenerateLinkerCommand ( dependencies
,
3502 GeneratePhonyTarget();
3507 MingwAliasModuleHandler::MingwAliasModuleHandler (
3508 const Module
& module_
)
3510 : MingwModuleHandler ( module_
)
3515 MingwAliasModuleHandler::Process ()
3520 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3521 const Module
& module_
)
3523 : MingwModuleHandler ( module_
)
3528 MingwCabinetModuleHandler::Process ()
3530 string
targetMacro ( GetTargetMacro (module
) );
3534 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3535 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3536 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3537 targetMacro
.c_str (),
3538 backend
->GetFullPath ( *target_file
).c_str () );
3540 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3541 fprintf ( fMakefile
,
3542 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3543 targetMacro
.c_str (),
3544 module
.name
.c_str());
3547 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3548 const Module
& module_
)
3550 : MingwModuleHandler ( module_
)
3555 MingwElfExecutableModuleHandler::Process ()
3557 string
targetName ( module
.output
->name
);
3558 string
targetMacro ( GetTargetMacro (module
) );
3559 string workingDirectory
= GetWorkingDirectory ();
3560 string objectsMacro
= GetObjectsMacro ( module
);
3561 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3562 string libsMacro
= GetLibsMacro ();
3566 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3567 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3568 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3569 targetMacro
.c_str (),
3570 objectsMacro
.c_str (),
3571 linkDepsMacro
.c_str (),
3572 backend
->GetFullPath ( *target_file
).c_str () );
3574 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3576 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -gstabs+ -o %s\n",
3577 module
.buildtype
.c_str(),
3578 objectsMacro
.c_str(),
3580 targetMacro
.c_str () );