2 * Copyright (C) 2005 Casper S. Hornstrup
3 * 2007-2008 Hervé Poussineau
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "../../pch.h"
23 #include "../../rbuild.h"
25 #include "modulehandler.h"
32 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
33 #define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
36 MingwModuleHandler::backend
= NULL
;
38 MingwModuleHandler::fMakefile
= NULL
;
42 const string
& filename
,
43 const string
& prefix
)
45 if ( !prefix
.length() )
48 const char* pfilename
= filename
.c_str();
49 const char* p1
= strrchr ( pfilename
, '/' );
50 const char* p2
= strrchr ( pfilename
, '\\' );
55 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
58 out
+= prefix
+ pfilename
;
63 GetTargetMacro ( const Module
& module
, bool with_dollar
)
65 string
s ( module
.name
);
69 return ssprintf ( "$(%s)", s
.c_str() );
73 MingwModuleHandler::MingwModuleHandler (
74 const Module
& module_
)
81 MingwModuleHandler::~MingwModuleHandler()
86 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
92 MingwModuleHandler::SetMakefile ( FILE* f
)
98 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
103 /*static*/ const FileLocation
*
104 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
106 switch ( file
->directory
)
108 case SourceDirectory
:
110 case IntermediateDirectory
:
111 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
113 case OutputDirectory
:
114 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
116 case InstallDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
120 throw InvalidOperationException ( __FILE__
,
122 "Invalid directory %d.",
129 /* caller needs to delete the returned object */
131 MingwModuleHandler::GetTargetFilename (
132 const Module
& module
,
133 string_list
* pclean_files
)
135 FileLocation
*target
= new FileLocation ( *module
.output
);
138 string_list
& clean_files
= *pclean_files
;
139 CLEAN_FILE ( *target
);
144 /* caller needs to delete the returned object */
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 FileLocation
*target
= new FileLocation ( *module
.dependency
);
153 string_list
& clean_files
= *pclean_files
;
154 CLEAN_FILE ( *target
);
159 /* caller needs to delete the returned object */
161 MingwModuleHandler::InstanciateHandler (
162 const Module
& module
,
163 MingwBackend
* backend
)
165 MingwModuleHandler
* handler
;
166 switch ( module
.type
)
169 case HostStaticLibrary
:
176 case EmbeddedTypeLib
:
178 handler
= new MingwModuleHandler( module
);
181 handler
= new MingwBuildToolModuleHandler ( module
);
184 handler
= new MingwKernelModuleHandler ( module
);
187 handler
= new MingwNativeCUIModuleHandler ( module
);
190 handler
= new MingwWin32CUIModuleHandler ( module
);
194 handler
= new MingwWin32GUIModuleHandler ( module
);
198 case KernelModeDriver
:
199 handler
= new MingwKernelModeDLLModuleHandler ( module
);
202 handler
= new MingwNativeDLLModuleHandler ( module
);
205 handler
= new MingwWin32DLLModuleHandler ( module
);
208 handler
= new MingwWin32OCXModuleHandler ( module
);
211 handler
= new MingwBootLoaderModuleHandler ( module
);
214 handler
= new MingwBootProgramModuleHandler ( module
);
217 handler
= new MingwIsoModuleHandler ( module
);
220 handler
= new MingwLiveIsoModuleHandler ( module
);
223 handler
= new MingwIsoModuleHandler ( module
);
226 handler
= new MingwLiveIsoModuleHandler ( module
);
229 handler
= new MingwTestModuleHandler ( module
);
232 handler
= new MingwAliasModuleHandler ( module
);
235 handler
= new MingwCabinetModuleHandler ( module
);
238 handler
= new MingwElfExecutableModuleHandler ( module
);
241 throw UnknownModuleTypeException (
242 module
.node
.location
,
250 MingwModuleHandler::GetWorkingDirectory () const
256 MingwModuleHandler::GetBasename ( const string
& filename
) const
258 size_t index
= filename
.find_last_of ( '.' );
259 if ( index
!= string::npos
)
260 return filename
.substr ( 0, index
);
265 MingwModuleHandler::GetCompilationUnitDependencies (
266 const CompilationUnit
& compilationUnit
) const
268 if ( compilationUnit
.GetFiles ().size () <= 1 )
270 vector
<string
> sourceFiles
;
271 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
273 const File
& file
= *compilationUnit
.GetFiles ()[i
];
274 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
276 return string ( " " ) + v2s ( sourceFiles
, 10 );
279 /* caller needs to delete the returned object */
281 MingwModuleHandler::GetModuleArchiveFilename () const
283 if ( IsStaticLibrary ( module
) )
284 return GetTargetFilename ( module
, NULL
);
285 return new FileLocation ( IntermediateDirectory
,
286 module
.output
->relative_path
,
287 ReplaceExtension ( module
.name
, ".temp.a" ) );
291 MingwModuleHandler::ReferenceObjects (
292 const Module
& module
)
294 if ( module
.type
== ObjectLibrary
)
296 if ( module
.type
== RpcServer
)
298 if ( module
.type
== RpcClient
)
300 if ( module
.type
== RpcProxy
)
302 if ( module
.type
== IdlHeader
)
304 if ( module
.type
== MessageHeader
)
310 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
311 const FileLocation
& destination
)
313 fprintf ( fMakefile
, "# OUTPUT COPY COMMAND\n" );
317 "\t${cp} %s %s 1>$(NUL)\n",
318 backend
->GetFullName ( source
).c_str (),
319 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
323 MingwModuleHandler::GetImportLibraryDependency (
324 const Module
& importedModule
)
327 if ( ReferenceObjects ( importedModule
) )
329 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
332 dep
= GetTargetMacro ( importedModule
);
333 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
335 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
336 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
337 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
338 if ( GetExtension ( *objectFilename
) == ".h" )
339 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
340 else if ( GetExtension ( *objectFilename
) == ".rc" )
341 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
346 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
347 dep
= backend
->GetFullName ( *library_target
);
348 delete library_target
;
351 if ( IsStaticLibrary ( importedModule
) || importedModule
.type
== ObjectLibrary
)
353 const std::vector
<Library
*>& libraries
= importedModule
.non_if_data
.libraries
;
355 for ( size_t i
= 0; i
< libraries
.size (); ++ i
)
358 dep
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
366 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
367 string_list
& targets
)
369 if ( dependencyModule
.invocations
.size () > 0 )
371 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
373 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
374 invoke
.GetTargets ( targets
);
378 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
382 MingwModuleHandler::GetModuleDependencies (
383 string_list
& dependencies
)
385 size_t iend
= module
.dependencies
.size ();
390 for ( size_t i
= 0; i
< iend
; i
++ )
392 const Dependency
& dependency
= *module
.dependencies
[i
];
393 const Module
& dependencyModule
= *dependency
.dependencyModule
;
394 GetTargets ( dependencyModule
,
397 vector
<FileLocation
> v
;
398 GetDefinitionDependencies ( v
);
400 for ( size_t i
= 0; i
< v
.size (); i
++ )
402 const FileLocation
& file
= v
[i
];
403 dependencies
.push_back ( backend
->GetFullName ( file
) );
407 /* caller needs to delete the returned object */
409 MingwModuleHandler::GetObjectFilename (
410 const FileLocation
* sourceFile
,
411 const Module
& module
) const
413 DirectoryLocation destination_directory
;
415 string extension
= GetExtension ( *sourceFile
);
417 if ( module
.type
== BootSector
)
418 return new FileLocation ( *module
.output
);
419 else if (extension
== ".rc")
420 newExtension
= "_" + module
.name
+ ".coff";
421 else if (extension
== ".mc")
422 newExtension
= ".rc";
423 else if (extension
== ".idl")
425 if ( module
.type
== RpcServer
)
426 newExtension
= "_s.o";
427 else if ( module
.type
== RpcClient
)
428 newExtension
= "_c.o";
429 else if ( module
.type
== RpcProxy
)
430 newExtension
= "_p.o";
435 newExtension
= "_" + module
.name
+ ".o";
437 if ( module
.type
== BootSector
)
438 destination_directory
= OutputDirectory
;
440 destination_directory
= IntermediateDirectory
;
442 const FileLocation
*obj_file
= new FileLocation(
443 destination_directory
,
444 sourceFile
->relative_path
,
445 ReplaceExtension ( sourceFile
->name
, newExtension
) );
446 PassThruCacheDirectory ( obj_file
);
452 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
454 return module
.name
+ "_clean";
458 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
460 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
462 Library
& library
= *module
.non_if_data
.libraries
[i
];
463 if ( library
.importedModule
->type
== ObjectLibrary
)
464 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
469 MingwModuleHandler::GenerateCleanTarget () const
471 if ( module
.type
== Alias
)
474 fprintf ( fMakefile
, "# CLEAN TARGET\n" );
476 ".PHONY: %s_clean\n",
477 module
.name
.c_str() );
478 vector
<string
> referencedModuleNames
;
479 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
482 GetModuleCleanTarget ( module
).c_str(),
483 v2s ( referencedModuleNames
, 10 ).c_str () );
484 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
486 if ( ( i
+ 1 ) % 10 == 9 )
487 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
488 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
490 fprintf ( fMakefile
, " 2>$(NUL)\n" );
492 if( ProxyMakefile::GenerateProxyMakefile(module
) )
494 DirectoryLocation root
;
496 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
497 root
= SourceDirectory
;
499 root
= OutputDirectory
;
501 FileLocation
proxyMakefile ( root
,
502 module
.output
->relative_path
,
504 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
505 backend
->GetFullName ( proxyMakefile
).c_str () );
508 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
512 MingwModuleHandler::GenerateInstallTarget () const
514 if ( !module
.install
)
516 fprintf ( fMakefile
, "# INSTALL TARGET\n" );
517 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
520 module
.name
.c_str (),
521 backend
->GetFullName ( *module
.install
).c_str () );
525 MingwModuleHandler::GenerateDependsTarget () const
527 fprintf ( fMakefile
, "# DEPENDS TARGET\n" );
529 ".PHONY: %s_depends\n",
530 module
.name
.c_str() );
532 "%s_depends: $(RBUILD_TARGET)\n",
533 module
.name
.c_str () );
535 "\t$(ECHO_RBUILD)\n" );
537 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
538 module
.name
.c_str () );
542 MingwModuleHandler::GenerateGccDefineParametersFromVector (
543 const vector
<Define
*>& defines
,
544 set
<string
>& used_defs
)
548 for ( size_t i
= 0; i
< defines
.size (); i
++ )
550 Define
& define
= *defines
[i
];
551 if (used_defs
.find(define
.name
) != used_defs
.end())
553 if (parameters
.length () > 0)
555 if (define
.name
.find('(') != string::npos
)
556 parameters
+= "$(QT)";
558 parameters
+= define
.name
;
559 if (define
.value
.length () > 0)
562 parameters
+= define
.value
;
564 if (define
.name
.find('(') != string::npos
)
565 parameters
+= "$(QT)";
566 used_defs
.insert(used_defs
.begin(),define
.name
);
572 MingwModuleHandler::ConcatenatePaths (
574 const string
& path2
) const
576 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
578 if ( path1
[path1
.length ()] == cSep
)
579 return path1
+ path2
;
581 return path1
+ cSep
+ path2
;
585 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
587 string parameters
, path_prefix
;
588 for ( size_t i
= 0; i
< includes
.size (); i
++ )
590 Include
& include
= *includes
[i
];
591 if ( parameters
.length () > 0 )
593 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);
599 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
602 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
604 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
605 if ( compilerFlag
.compiler
== type
)
606 parameters
+= " " + compilerFlag
.flag
;
612 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
615 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
617 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
618 if ( parameters
.length () > 0 )
620 parameters
+= linkerFlag
.flag
;
626 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
627 const vector
<Library
*>& libraries
)
629 string
dependencies ( "" );
631 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
633 if ( wrap_count
++ == 5 )
634 dependencies
+= " \\\n\t\t", wrap_count
= 0;
635 else if ( dependencies
.size () > 0 )
637 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
643 MingwModuleHandler::GenerateLinkerParameters () const
645 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
649 MingwModuleHandler::GenerateMacro (
650 const char* assignmentOperation
,
652 const IfableData
& data
,
653 set
<const Define
*> *used_defs
,
654 bool generatingCompilerMacro
)
657 bool generateAssignment
;
659 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
660 if ( generatingCompilerMacro
)
661 generateAssignment
|= data
.compilerFlags
.size () > 0;
662 if ( generateAssignment
)
667 assignmentOperation
);
670 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
675 backend
->GetFullPath ( *pchFilename
).c_str () );
679 if ( generatingCompilerMacro
)
681 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
682 if ( compilerParameters
.size () > 0 )
687 compilerParameters
.c_str () );
690 for ( i
= 0; i
< data
.includes
.size(); i
++ )
692 const Include
& include
= *data
.includes
[i
];
693 const FileLocation
* includeDirectory
= include
.directory
;
697 backend
->GetFullPath ( *includeDirectory
).c_str() );
699 for ( i
= 0; i
< data
.defines
.size(); i
++ )
701 const Define
& define
= *data
.defines
[i
];
704 set
<const Define
*>::const_iterator last_define
;
705 for (last_define
= used_defs
->begin ();
706 last_define
!= used_defs
->end ();
709 if ( (*last_define
)->name
!= define
.name
)
711 if ( !define
.overridable
)
713 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
715 "Invalid override of define '%s', already defined at %s",
716 define
.name
.c_str (),
717 define
.node
->location
.c_str () );
719 if ( backend
->configuration
.Verbose
)
720 printf("%s: Overriding '%s' already defined at %s\n",
721 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
722 define
.node
->location
.c_str () );
725 if ( last_define
!= used_defs
->end () )
731 define
.name
.c_str() );
732 if (define
.value
.length () > 0)
736 define
.value
.c_str() );
738 used_defs
->insert( used_defs
->begin (), &define
);
740 if ( generateAssignment
)
742 fprintf ( fMakefile
, "\n" );
747 MingwModuleHandler::GenerateMacros (
748 const char* assignmentOperation
,
749 const IfableData
& data
,
750 const vector
<LinkerFlag
*>* linkerFlags
,
751 set
<const Define
*>& used_defs
)
753 fprintf ( fMakefile
, "# MACROS\n" );
754 GenerateMacro ( assignmentOperation
,
759 GenerateMacro ( assignmentOperation
,
765 if ( linkerFlags
!= NULL
)
767 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
768 if ( linkerParameters
.size () > 0 )
773 linkerflagsMacro
.c_str (),
775 linkerParameters
.c_str() );
779 if ( data
.libraries
.size () > 0 )
781 // Check if host and target modules are not mixed up
782 HostType current
= ModuleHandlerInformations
[module
.type
].DefaultHost
;
783 std::vector
<Library
*>::const_iterator it
;
784 for ( it
= data
.libraries
.begin(); it
!= data
.libraries
.end(); ++it
)
786 HostType imported
= ModuleHandlerInformations
[(*it
)->importedModule
->type
].DefaultHost
;
787 if (current
!= imported
)
789 throw InvalidOperationException ( __FILE__
,
791 "Module '%s' imports module '%s', which is not of the right type",
792 module
.name
.c_str (),
793 (*it
)->importedModule
->name
.c_str () );
797 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
798 if ( deps
.size () > 0 )
811 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
813 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
814 delete compilationUnits
[i
];
818 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
823 MingwModuleHandler::GenerateSourceMacros (
824 const IfableData
& data
)
828 fprintf ( fMakefile
, "# SOURCE MACROS\n" );
829 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
830 vector
<const FileLocation
*> headers
;
831 if ( compilationUnits
.size () > 0 )
836 sourcesMacro
.c_str () );
837 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
839 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
840 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
844 ( i
%10 == 9 ? " \\\n\t" : " " ),
845 backend
->GetFullName ( compilationName
).c_str () );
847 fprintf ( fMakefile
, "\n" );
850 vector
<CompilationUnit
*> sourceCompilationUnits
;
851 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
852 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
854 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
858 sourcesMacro
.c_str(),
859 backend
->GetFullName ( compilationName
).c_str () );
861 CleanupCompilationUnitVector ( sourceCompilationUnits
);
865 MingwModuleHandler::GenerateObjectMacros (
866 const IfableData
& data
)
869 const char* assignmentOperation
= "=";
871 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
872 vector
<const FileLocation
*> headers
;
873 vector
<const FileLocation
*> mcheaders
;
874 vector
<const FileLocation
*> mcresources
;
875 fprintf ( fMakefile
, "# OBJECT MACROS\n" );
876 if ( compilationUnits
.size () > 0 )
878 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
880 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
881 if ( compilationUnit
.IsFirstFile () )
883 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
884 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
887 objectsMacro
.c_str(),
888 backend
->GetFullName ( *object_file
).c_str () );
890 assignmentOperation
= "+=";
897 objectsMacro
.c_str (),
898 assignmentOperation
);
899 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
901 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
902 if ( !compilationUnit
.IsFirstFile () )
904 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
905 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
906 if ( GetExtension ( *objectFilename
) == ".h" )
907 headers
.push_back ( objectFilename
);
908 else if ( GetExtension ( *objectFilename
) == ".rc" )
910 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
911 mcheaders
.push_back ( headerFilename
);
912 mcresources
.push_back ( objectFilename
);
919 ( i
%10 == 9 ? " \\\n\t" : " " ),
920 backend
->GetFullName ( *objectFilename
).c_str () );
921 delete objectFilename
;
925 fprintf ( fMakefile
, "\n" );
927 if ( headers
.size () > 0 )
932 module
.name
.c_str (),
933 assignmentOperation
);
934 for ( i
= 0; i
< headers
.size (); i
++ )
939 ( i
%10 == 9 ? " \\\n\t" : " " ),
940 backend
->GetFullName ( *headers
[i
] ).c_str () );
943 fprintf ( fMakefile
, "\n" );
946 if ( mcheaders
.size () > 0 )
951 module
.name
.c_str (),
952 assignmentOperation
);
953 for ( i
= 0; i
< mcheaders
.size (); i
++ )
958 ( i
%10 == 9 ? " \\\n\t" : " " ),
959 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
962 fprintf ( fMakefile
, "\n" );
965 if ( mcresources
.size () > 0 )
970 module
.name
.c_str (),
971 assignmentOperation
);
972 for ( i
= 0; i
< mcresources
.size (); i
++ )
977 ( i
%10 == 9 ? " \\\n\t" : " " ),
978 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
979 delete mcresources
[i
];
981 fprintf ( fMakefile
, "\n" );
984 vector
<CompilationUnit
*> sourceCompilationUnits
;
985 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
986 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
988 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
989 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
993 objectsMacro
.c_str(),
994 backend
->GetFullName ( *object_file
).c_str () );
997 CleanupCompilationUnitVector ( sourceCompilationUnits
);
999 if ( IsSpecDefinitionFile() )
1001 const FileLocation
*stubs_file
= new FileLocation(
1002 IntermediateDirectory
,
1003 module
.importLibrary
->source
->relative_path
,
1004 ReplaceExtension ( module
.importLibrary
->source
->name
, "_" + module
.name
+ ".stubs.o" ) );
1009 objectsMacro
.c_str(),
1010 backend
->GetFullName ( *stubs_file
).c_str () );
1015 if ( module
.type
== RpcProxy
)
1017 const FileLocation
*dlldata_file
= GetDlldataFilename();
1022 objectsMacro
.c_str(),
1023 ReplaceExtension ( backend
->GetFullName ( *dlldata_file
), ".o" ).c_str() );
1025 delete dlldata_file
;
1030 MingwModuleHandler::GetDlldataFilename() const
1032 std::string dlldata_path
= "";
1033 size_t dlldata_path_len
= module
.xmlbuildFile
.find_last_of(cSep
);
1035 if ( dlldata_path_len
!= std::string::npos
&& dlldata_path_len
!= 0 )
1036 dlldata_path
= module
.xmlbuildFile
.substr(0, dlldata_path_len
);
1038 return new FileLocation( IntermediateDirectory
, dlldata_path
, module
.name
+ ".dlldata.c" );
1041 /* caller needs to delete the returned object */
1043 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1045 if ( !module
.pch
|| !use_pch
)
1047 return new FileLocation ( IntermediateDirectory
,
1048 module
.pch
->file
->relative_path
+ "/.gch_" + module
.name
,
1049 module
.pch
->file
->name
+ ".gch" );
1052 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) $(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1053 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1054 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1055 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1056 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1058 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1059 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1061 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1062 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1064 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1065 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1066 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1067 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1068 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1070 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1071 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1072 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1073 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1075 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1076 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1077 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1078 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1079 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1081 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1082 "\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"
1083 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1084 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1085 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1086 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1087 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1088 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"
1090 "\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",
1091 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1092 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1093 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1094 Rule
winebuildPDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1096 "\t${gcc} -xc -E ${$(module_name)_RCFLAGS} $(source) > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec\n\n"
1097 "$(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"
1098 "\t$(ECHO_WINEBLD)\n"
1099 "\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",
1100 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec",
1101 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1102 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1103 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"
1104 "\t$(ECHO_WINEBLD)\n"
1105 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec --filename $(module_dllname)\n\n"
1106 "$(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"
1108 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1109 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec",
1110 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1111 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1112 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1113 Rule
winebuildDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1114 "\t$(ECHO_WINEBLD)\n"
1115 "\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",
1116 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
1117 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1118 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1119 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1120 "\t$(ECHO_WINEBLD)\n"
1121 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(source_path)$(SEP)$(source_name_noext).spec --filename $(module_dllname)\n"
1122 "$(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"
1124 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1125 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1126 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1127 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1128 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1129 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1131 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1132 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1133 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1134 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1135 "$(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"
1137 "\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"
1138 "$(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"
1140 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1141 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1142 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1143 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1144 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1145 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1146 "$(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"
1148 "\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"
1149 "$(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"
1151 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1152 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1153 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1154 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1155 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1156 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1157 "$(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"
1159 "\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"
1160 "$(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"
1162 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1163 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1164 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1165 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1166 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1167 Rule
widlDlldataRule ( "$(source): $(dependencies) ${$(module_name)_precondition} $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1169 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) --dlldata-only --dlldata=$(source) $(bare_dependencies)\n"
1170 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).o: $(source) $(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1172 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1173 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).o", NULL
);
1174 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1175 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1177 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1178 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1179 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1180 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1182 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1183 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1184 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1185 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1186 "\t$(ECHO_HOSTCC)\n"
1187 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1188 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1189 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1190 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1192 "\t${gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1193 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1194 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1195 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1196 "\t$(ECHO_HOSTCC)\n"
1197 "\t${host_gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1198 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1199 Rule
emptyRule ( "", NULL
);
1202 MingwModuleHandler::GenerateGccCommand (
1203 const FileLocation
* sourceFile
,
1205 const string
& extraDependencies
)
1207 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1208 string dependencies
= extraDependencies
;
1211 string extension
= GetExtension ( *sourceFile
);
1212 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1213 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1215 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1219 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1223 /* WIDL generated headers may be used */
1224 vector
<FileLocation
> rpcDependencies
;
1225 GetRpcHeaderDependencies ( rpcDependencies
);
1226 if ( rpcDependencies
.size () > 0 )
1227 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1229 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1233 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1235 const Property
* property
= module
.project
.LookupProperty(name
);
1238 return property
->value
;
1240 return string ( "" );
1243 /* caller needs to delete the returned object */
1245 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1247 string newname
= GetBasename ( base
->name
) + "_s.h";
1248 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1251 /* caller needs to delete the returned object */
1253 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1255 string newname
= GetBasename ( base
->name
) + "_c.h";
1256 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1259 /* caller needs to delete the returned object */
1261 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1263 string newname
= GetBasename ( base
->name
) + "_p.h";
1264 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1267 /* caller needs to delete the returned object */
1269 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1271 string newname
= GetBasename ( base
->name
) + ".h";
1272 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1275 /* caller needs to delete the returned object */
1277 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1279 string newname
= GetBasename ( base
->name
) + ".h";
1280 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1284 MingwModuleHandler::GenerateCommands (
1285 const CompilationUnit
& compilationUnit
,
1286 const string
& extraDependencies
)
1288 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1289 string extension
= GetExtension ( sourceFile
);
1290 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1299 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1300 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1301 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1302 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1303 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1304 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1305 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1306 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1307 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1308 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1309 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1310 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1311 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1312 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1313 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1314 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1315 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1316 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1317 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1320 Rule
*customRule
= NULL
;
1322 fprintf ( fMakefile
, "# COMMANDS\n" );
1324 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1326 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1328 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1330 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1332 customRule
= rules
[i
].rule
;
1336 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1338 GenerateGccCommand ( &sourceFile
,
1340 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1342 else if ( customRule
)
1343 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1346 throw InvalidOperationException ( __FILE__
,
1348 "Unsupported filename extension '%s' in file '%s'",
1350 backend
->GetFullName ( sourceFile
).c_str () );
1355 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1357 fprintf ( fMakefile
, "# BUILD MAP CODE\n" );
1359 fprintf ( fMakefile
,
1360 "ifeq ($(ROS_BUILDMAP),full)\n" );
1362 FileLocation
mapFilename ( OutputDirectory
,
1363 module
.output
->relative_path
,
1364 GetBasename ( module
.output
->name
) + ".map" );
1365 CLEAN_FILE ( mapFilename
);
1367 fprintf ( fMakefile
,
1368 "\t$(ECHO_OBJDUMP)\n" );
1369 fprintf ( fMakefile
,
1370 "\t$(Q)${objdump} -d -S %s > %s\n",
1371 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1372 backend
->GetFullName ( mapFilename
).c_str () );
1374 fprintf ( fMakefile
,
1376 fprintf ( fMakefile
,
1377 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1379 fprintf ( fMakefile
,
1381 fprintf ( fMakefile
,
1382 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1383 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1384 backend
->GetFullName ( mapFilename
).c_str () );
1386 fprintf ( fMakefile
,
1389 fprintf ( fMakefile
,
1394 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1396 fprintf ( fMakefile
, "# BUILD NO STRIP CODE\n" );
1398 fprintf ( fMakefile
,
1399 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1401 FileLocation
nostripFilename ( OutputDirectory
,
1402 module
.output
->relative_path
,
1403 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1404 CLEAN_FILE ( nostripFilename
);
1406 OutputCopyCommand ( *module
.output
, nostripFilename
);
1408 fprintf ( fMakefile
,
1413 MergeStringVector ( const Backend
* backend
,
1414 const vector
<FileLocation
>& input
,
1415 vector
<string
>& output
)
1419 int wrap_count
= -1;
1420 for ( size_t i
= 0; i
< input
.size (); i
++ )
1422 if ( wrap_count
++ == wrap_at
)
1424 output
.push_back ( s
);
1428 else if ( s
.size () > 0)
1430 s
+= backend
->GetFullName ( input
[i
] );
1432 if ( s
.length () > 0 )
1433 output
.push_back ( s
);
1437 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1438 vector
<FileLocation
>& objectFiles
) const
1440 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1442 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1443 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1444 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1445 objectFiles
.push_back ( *object_file
);
1451 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1453 if ( backend
->configuration
.CleanAsYouGo
)
1455 vector
<FileLocation
> objectFiles
;
1456 GetObjectsVector ( module
.non_if_data
,
1458 vector
<string
> lines
;
1459 MergeStringVector ( backend
,
1462 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1464 fprintf ( fMakefile
,
1465 "\t-@${rm} %s 2>$(NUL)\n",
1466 lines
[i
].c_str () );
1472 MingwModuleHandler::GenerateRunRsymCode () const
1474 fprintf ( fMakefile
, "# RUN RSYM CODE\n" );
1475 fprintf ( fMakefile
,
1476 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1477 fprintf ( fMakefile
,
1478 "\t$(ECHO_RSYM)\n" );
1479 fprintf ( fMakefile
,
1480 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1481 fprintf ( fMakefile
,
1486 MingwModuleHandler::GenerateRunStripCode () const
1488 fprintf ( fMakefile
, "# RUN STRIP CODE\n" );
1489 fprintf ( fMakefile
,
1490 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1491 fprintf ( fMakefile
,
1492 "\t$(ECHO_STRIP)\n" );
1493 fprintf ( fMakefile
,
1494 "\t${strip} -s -x -X $@\n\n" );
1495 fprintf ( fMakefile
,
1500 MingwModuleHandler::GenerateLinkerCommand (
1501 const string
& dependencies
,
1502 const string
& linkerParameters
,
1503 const string
& pefixupParameters
)
1505 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1506 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1507 string linker
= "${ld}";
1508 string objectsMacro
= GetObjectsMacro ( module
);
1509 string libsMacro
= GetLibsMacro ();
1511 fprintf ( fMakefile
, "# LINKER COMMAND\n" );
1513 string
target_macro ( GetTargetMacro ( module
) );
1514 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1516 string linkerScriptArgument
;
1517 if ( module
.linkerScript
!= NULL
)
1518 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1520 linkerScriptArgument
= "";
1522 /* check if we need to add default C++ libraries, ie if we have
1523 * a C++ user-mode module without the -nostdlib linker flag
1525 bool link_defaultlibs
= module
.cplusplus
&&
1526 linkerParameters
.find ("-nostdlib") == string::npos
&&
1527 !(module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
);
1529 if ( !module
.HasImportLibrary() )
1531 fprintf ( fMakefile
,
1532 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1533 target_macro
.c_str (),
1534 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1535 dependencies
.c_str (),
1536 target_folder
.c_str () );
1537 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1539 fprintf ( fMakefile
,
1540 "\t%s %s%s %s %s %s %s -o %s\n",
1542 linkerParameters
.c_str (),
1543 linkerScriptArgument
.c_str (),
1544 objectsMacro
.c_str (),
1545 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1547 GetLinkerMacro ().c_str (),
1548 target_macro
.c_str () );
1552 FileLocation
temp_exp ( IntermediateDirectory
,
1553 module
.output
->relative_path
,
1554 module
.name
+ ".exp" );
1555 CLEAN_FILE ( temp_exp
);
1557 fprintf ( fMakefile
,
1559 backend
->GetFullName ( temp_exp
).c_str (),
1560 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1561 backend
->GetFullPath ( temp_exp
).c_str () );
1562 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1564 fprintf ( fMakefile
,
1565 "\t${dlltool} --dllname %s --def %s --output-exp $@%s%s\n",
1566 module
.GetDllName ().c_str (),
1567 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1568 module
.mangledSymbols
? "" : " --kill-at",
1569 module
.underscoreSymbols
? " --add-underscore" : "" );
1571 fprintf ( fMakefile
,
1572 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1573 target_macro
.c_str (),
1574 backend
->GetFullName ( temp_exp
).c_str (),
1575 dependencies
.c_str (),
1576 target_folder
.c_str () );
1577 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1579 fprintf ( fMakefile
,
1580 "\t%s %s%s %s %s %s %s %s -o %s\n",
1583 linkerParameters
.c_str (),
1584 linkerScriptArgument
.c_str (),
1585 backend
->GetFullName ( temp_exp
).c_str (),
1586 objectsMacro
.c_str (),
1587 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1589 GetLinkerMacro ().c_str (),
1590 target_macro
.c_str () );
1592 fprintf ( fMakefile
,
1593 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1594 target_macro
.c_str (),
1595 pefixupParameters
.c_str() );
1598 GenerateBuildMapCode ();
1599 GenerateBuildNonSymbolStrippedCode ();
1600 GenerateRunRsymCode ();
1601 GenerateRunStripCode ();
1602 GenerateCleanObjectsAsYouGoCode ();
1604 if ( definitionFilename
)
1605 delete definitionFilename
;
1610 MingwModuleHandler::GeneratePhonyTarget() const
1612 string
targetMacro ( GetTargetMacro ( module
) );
1613 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1615 fprintf ( fMakefile
, "# PHONY TARGET\n" );
1616 fprintf ( fMakefile
,
1618 targetMacro
.c_str ());
1619 fprintf ( fMakefile
, "%s: | %s\n",
1620 targetMacro
.c_str (),
1621 backend
->GetFullPath ( *target_file
).c_str () );
1627 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1630 string moduleDependencies
;
1632 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1634 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1635 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1637 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1638 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1639 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1640 if ( GetExtension ( *objectFilename
) == ".h" )
1641 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1642 else if ( GetExtension ( *objectFilename
) == ".rc" )
1643 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1644 delete objectFilename
;
1647 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1649 GenerateCommands ( *compilationUnits
[i
],
1650 moduleDependencies
);
1651 fprintf ( fMakefile
,
1655 vector
<CompilationUnit
*> sourceCompilationUnits
;
1656 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1657 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1659 GenerateCommands ( *sourceCompilationUnits
[i
],
1660 moduleDependencies
);
1662 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1664 SpecFileType spec
= IsSpecDefinitionFile ();
1671 defRule
= &winebuildPRule
;
1673 defRule
= &winebuildRule
;
1675 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
1678 if ( module
.type
== RpcProxy
)
1680 widlDlldataRule
.Execute ( fMakefile
,
1683 GetDlldataFilename(),
1685 ssprintf ( "$(%s_SOURCES)", module
.name
.c_str ()) );
1690 MingwModuleHandler::GenerateObjectFileTargets ()
1692 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1694 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1698 string cc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gcc}" : "${gcc}" );
1699 string cppc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gpp}" : "${gpp}" );
1701 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1702 CLEAN_FILE ( *pchFilename
);
1703 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1704 /* WIDL generated headers may be used */
1705 vector
<FileLocation
> rpcDependencies
;
1706 GetRpcHeaderDependencies ( rpcDependencies
);
1707 if ( rpcDependencies
.size () > 0 )
1708 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1709 fprintf ( fMakefile
,
1711 backend
->GetFullName ( *pchFilename
).c_str(),
1712 dependencies
.c_str(),
1713 backend
->GetFullPath ( *pchFilename
).c_str() );
1714 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1715 fprintf ( fMakefile
,
1716 "\t%s -o %s %s %s -gstabs+ -x %s %s\n\n",
1718 backend
->GetFullName ( *pchFilename
).c_str(),
1719 module
.cplusplus
? cxxflagsMacro
.c_str() : cflagsMacro
.c_str(),
1720 GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, module
.cplusplus
? CompilerTypeCPP
: CompilerTypeCC
).c_str(),
1721 module
.cplusplus
? "c++-header" : "c-header",
1722 backend
->GetFullName ( baseHeaderFile
).c_str() );
1726 GenerateObjectFileTargets ( module
.non_if_data
);
1727 fprintf ( fMakefile
, "\n" );
1730 /* caller needs to delete the returned object */
1732 MingwModuleHandler::GenerateArchiveTarget ()
1734 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1735 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1737 fprintf ( fMakefile
, "# ARCHIVE TARGET\n" );
1739 if ( IsStaticLibrary ( module
) && definitionFilename
)
1741 arRule1
.Execute ( fMakefile
,
1746 backend
->GetFullName ( *definitionFilename
).c_str () );
1748 fprintf ( fMakefile
,
1749 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1750 module
.GetDllName ().c_str (),
1751 backend
->GetFullName ( *definitionFilename
).c_str (),
1752 module
.mangledSymbols
? "" : " --kill-at",
1753 module
.underscoreSymbols
? " --add-underscore" : "" );
1756 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1758 if ( definitionFilename
)
1759 delete definitionFilename
;
1761 if(module
.type
== HostStaticLibrary
)
1762 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1764 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1766 GenerateCleanObjectsAsYouGoCode ();
1768 fprintf ( fMakefile
, "\n" );
1770 return archiveFilename
;
1774 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1776 return ssprintf ( "$(%s_OBJS)",
1777 module
.name
.c_str () );
1781 MingwModuleHandler::GetLinkingDependenciesMacro () const
1783 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1787 MingwModuleHandler::GetLibsMacro () const
1789 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1793 MingwModuleHandler::GetLinkerMacro () const
1795 return ssprintf ( "$(%s_LFLAGS)",
1796 module
.name
.c_str () );
1800 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1802 if ( ReferenceObjects ( module
) )
1803 return GetObjectsMacro ( module
);
1806 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1807 string target
= backend
->GetFullName ( *target_file
).c_str ();
1814 MingwModuleHandler::GenerateSourceMacro ()
1816 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1818 GenerateSourceMacros ( module
.non_if_data
);
1820 // future references to the macro will be to get its values
1821 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1825 MingwModuleHandler::GenerateObjectMacro ()
1827 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1829 GenerateObjectMacros ( module
.non_if_data
);
1831 // future references to the macro will be to get its values
1832 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1836 MingwModuleHandler::GenerateTargetMacro ()
1838 fprintf ( fMakefile
, "# TARGET MACRO\n" );
1839 fprintf ( fMakefile
,
1841 GetTargetMacro ( module
, false ).c_str (),
1842 GetModuleTargets ( module
).c_str () );
1846 MingwModuleHandler::GetRpcHeaderDependencies (
1847 vector
<FileLocation
>& dependencies
) const
1849 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1851 Library
& library
= *module
.non_if_data
.libraries
[i
];
1852 if ( library
.importedModule
->type
== RpcServer
||
1853 library
.importedModule
->type
== RpcClient
||
1854 library
.importedModule
->type
== RpcProxy
||
1855 library
.importedModule
->type
== IdlHeader
)
1857 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1859 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1860 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1861 string extension
= GetExtension ( sourceFile
);
1862 if ( extension
== ".idl" || extension
== ".IDL" )
1864 string basename
= GetBasename ( sourceFile
.name
);
1865 if ( library
.importedModule
->type
== RpcServer
)
1867 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1868 dependencies
.push_back ( *header
);
1871 if ( library
.importedModule
->type
== RpcClient
)
1873 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1874 dependencies
.push_back ( *header
);
1877 if ( library
.importedModule
->type
== RpcProxy
)
1879 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1880 dependencies
.push_back ( *header
);
1883 if ( library
.importedModule
->type
== IdlHeader
)
1885 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1886 dependencies
.push_back ( *header
);
1896 MingwModuleHandler::GenerateOtherMacros ()
1898 set
<const Define
*> used_defs
;
1900 fprintf ( fMakefile
, "# OTHER MACROS\n" );
1902 commonflagsMacro
= ssprintf ("%s_COMMONFLAGS", module
.name
.c_str ());
1903 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1904 cxxflagsMacro
= ssprintf ("%s_CXXFLAGS", module
.name
.c_str ());
1905 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1906 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1907 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1908 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1909 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1910 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1915 &module
.linkerFlags
,
1918 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1920 GenerateMacros("+=", module
.project
.host_non_if_data
, NULL
, used_defs
);
1926 module
.project
.non_if_data
,
1931 if ( IsSpecDefinitionFile() )
1933 vector
<FileLocation
> s
;
1934 GetSpecImplibDependencies ( s
, module
.importLibrary
->source
);
1939 linkDepsMacro
.c_str() );
1940 for ( size_t i
= 0; i
< s
.size(); i
++ )
1941 fprintf ( fMakefile
,
1943 backend
->GetFullName ( s
[i
] ).c_str () );
1944 fprintf ( fMakefile
, "\n" );
1947 string globalCflags
= " ";
1948 globalCflags
+= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
1949 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1951 if ( module
.dynamicCRT
)
1952 globalCflags
+= " -D_DLL -D__USE_CRTIMP";
1955 globalCflags
+= " -Wall -Wpointer-arith";
1956 globalCflags
+= " -gstabs+";
1957 if ( backend
->usePipe
)
1958 globalCflags
+= " -pipe";
1959 if ( !module
.allowWarnings
)
1960 globalCflags
+= " -Werror";
1961 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1963 if ( module
.cplusplus
)
1964 globalCflags
+= " $(HOST_CPPFLAGS)";
1966 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
1970 if ( module
.cplusplus
)
1972 globalCflags
+= " $(TARGET_CPPFLAGS)";
1975 globalCflags
+= " -nostdinc";
1978 // Always force disabling of sibling calls optimisation for GCC
1979 // (TODO: Move to version-specific once this bug is fixed in GCC)
1980 globalCflags
+= " -fno-optimize-sibling-calls";
1982 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1987 cflagsMacro
.c_str (),
1988 (" $(PROJECT_CFLAGS)" + globalCflags
).c_str () );
1993 cxxflagsMacro
.c_str (),
1994 (" $(PROJECT_CXXFLAGS)" + globalCflags
).c_str () );
1998 "%s += $(PROJECT_RCFLAGS)\n",
1999 windresflagsMacro
.c_str () );
2003 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
2004 widlflagsMacro
.c_str (),
2005 module
.output
->relative_path
.c_str () );
2009 "%s_LFLAGS := $(PROJECT_LFLAGS) $(%s_LFLAGS)\n",
2010 module
.name
.c_str (),
2011 module
.name
.c_str () );
2018 cflagsMacro
.c_str (),
2019 globalCflags
.c_str () );
2024 cxxflagsMacro
.c_str (),
2025 globalCflags
.c_str () );
2029 "%s_LFLAGS += $(HOST_LFLAGS)\n",
2030 module
.name
.c_str () );
2036 linkDepsMacro
.c_str (),
2037 libsMacro
.c_str () );
2039 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
2040 if ( strlen( cflags
) > 0 )
2042 fprintf ( fMakefile
,
2044 cflagsMacro
.c_str (),
2046 fprintf ( fMakefile
,
2048 cxxflagsMacro
.c_str (),
2052 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
2053 if ( strlen( nasmflags
) > 0 )
2055 fprintf ( fMakefile
,
2057 nasmflagsMacro
.c_str (),
2061 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
2062 if ( strlen( linkerflags
) > 0 )
2064 fprintf ( fMakefile
,
2066 linkerflagsMacro
.c_str (),
2070 fprintf ( fMakefile
, "\n\n" );
2072 // future references to the macros will be to get their values
2073 commonflagsMacro
= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
2074 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2075 cxxflagsMacro
= ssprintf ("$(%s)", cxxflagsMacro
.c_str ());
2076 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2077 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2081 MingwModuleHandler::GenerateRules ()
2085 fprintf ( fMakefile
, "# RULES\n" );
2086 string targetMacro
= GetTargetMacro ( module
);
2087 //CLEAN_FILE ( targetMacro );
2088 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2090 // generate phony target for module name
2091 fprintf ( fMakefile
, ".PHONY: %s\n",
2092 module
.name
.c_str () );
2093 string dependencies
= GetTargetMacro ( module
);
2094 if ( module
.type
== Test
)
2095 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2096 fprintf ( fMakefile
, "%s: %s\n\n",
2097 module
.name
.c_str (),
2098 dependencies
.c_str () );
2099 if ( module
.type
== Test
)
2101 fprintf ( fMakefile
,
2103 targetMacro
.c_str ());
2106 if ( !ReferenceObjects ( module
) )
2108 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2113 spec
= IsSpecDefinitionFile();
2120 defRule
= &winebuildPDefRule
;
2122 defRule
= &winebuildDefRule
;
2124 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
2127 GenerateObjectFileTargets ();
2131 MingwModuleHandler::GetInvocationDependencies (
2132 const Module
& module
,
2133 string_list
& dependencies
)
2135 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2137 Invoke
& invoke
= *module
.invocations
[i
];
2138 if ( invoke
.invokeModule
== &module
)
2139 /* Protect against circular dependencies */
2141 invoke
.GetTargets ( dependencies
);
2146 MingwModuleHandler::GenerateInvocations () const
2148 if ( module
.invocations
.size () == 0 )
2151 fprintf ( fMakefile
, "# INVOCATIONS\n" );
2153 size_t iend
= module
.invocations
.size ();
2154 for ( size_t i
= 0; i
< iend
; i
++ )
2156 const Invoke
& invoke
= *module
.invocations
[i
];
2158 if ( invoke
.invokeModule
->type
!= BuildTool
)
2160 throw XMLInvalidBuildFileException (
2161 module
.node
.location
,
2162 "Only modules of type buildtool can be invoked." );
2165 string invokeTarget
= module
.GetInvocationTarget ( i
);
2166 string_list invoke_targets
;
2167 assert ( invoke_targets
.size() );
2168 invoke
.GetTargets ( invoke_targets
);
2169 fprintf ( fMakefile
,
2171 invokeTarget
.c_str () );
2172 fprintf ( fMakefile
,
2174 invokeTarget
.c_str () );
2175 size_t j
, jend
= invoke_targets
.size();
2176 for ( j
= 0; j
< jend
; j
++ )
2178 fprintf ( fMakefile
,
2180 invoke_targets
[i
].c_str () );
2182 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2183 for ( j
= 1; j
< jend
; j
++ )
2184 fprintf ( fMakefile
,
2186 invoke_targets
[i
].c_str () );
2187 fprintf ( fMakefile
,
2189 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2190 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2191 fprintf ( fMakefile
,
2193 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2194 invoke
.GetParameters ().c_str () );
2199 MingwModuleHandler::GetPreconditionDependenciesName () const
2201 return module
.name
+ "_precondition";
2205 MingwModuleHandler::GetDefaultDependencies (
2206 string_list
& dependencies
) const
2208 /* Avoid circular dependency */
2209 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2212 if (module
.name
!= "psdk" &&
2213 module
.name
!= "dxsdk")
2215 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2216 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2219 if (module
.name
!= "errcodes" &&
2220 module
.name
!= "bugcodes" &&
2221 module
.name
!= "ntstatus")
2223 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2224 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2225 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2228 ///* Check if any dependent library relies on the generated headers */
2229 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2231 // const Module& m = *module.project.modules[i];
2232 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2234 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2235 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2236 // string extension = GetExtension ( sourceFile );
2237 // if (extension == ".mc" || extension == ".MC" )
2239 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2240 // dependencies.push_back ( dependency );
2247 MingwModuleHandler::GeneratePreconditionDependencies ()
2249 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
2250 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2251 string_list dependencies
;
2252 GetDefaultDependencies ( dependencies
);
2253 GetModuleDependencies ( dependencies
);
2255 GetInvocationDependencies ( module
, dependencies
);
2257 if ( dependencies
.size() )
2259 fprintf ( fMakefile
,
2261 preconditionDependenciesName
.c_str () );
2262 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2263 fprintf ( fMakefile
,
2265 dependencies
[i
].c_str () );
2266 fprintf ( fMakefile
, "\n\n" );
2269 fprintf ( fMakefile
, "\n" );
2273 MingwModuleHandler::IsSpecDefinitionFile () const
2275 if(!module
.importLibrary
)
2278 std::string ext
= GetExtension ( *module
.importLibrary
->source
);
2280 if ( ext
== ".spec" )
2283 if ( ext
== ".pspec" )
2289 /* caller needs to delete the returned object */
2291 MingwModuleHandler::GetDefinitionFilename () const
2293 if ( module
.importLibrary
== NULL
)
2296 if ( IsSpecDefinitionFile () )
2298 return new FileLocation ( IntermediateDirectory
,
2299 module
.importLibrary
->source
->relative_path
,
2300 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2304 return new FileLocation ( SourceDirectory
,
2305 module
.importLibrary
->source
->relative_path
,
2306 module
.importLibrary
->source
->name
);
2311 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2313 if ( module
.importLibrary
!= NULL
)
2315 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2316 const FileLocation
*defFilename
= GetDefinitionFilename ();
2317 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2319 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE\n" );
2321 fprintf ( fMakefile
, "%s:",
2322 backend
->GetFullName ( *library_target
).c_str () );
2326 fprintf ( fMakefile
, " %s",
2327 backend
->GetFullName ( *defFilename
).c_str () );
2330 fprintf ( fMakefile
, " | %s\n",
2331 backend
->GetFullPath ( *library_target
).c_str () );
2333 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2335 fprintf ( fMakefile
,
2336 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2337 module
.GetDllName ().c_str (),
2338 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2340 backend
->GetFullName ( *library_target
).c_str (),
2341 module
.mangledSymbols
? "" : " --kill-at",
2342 module
.underscoreSymbols
? " --add-underscore" : "" );
2346 delete library_target
;
2351 MingwModuleHandler::GetSpecObjectDependencies (
2352 vector
<FileLocation
>& dependencies
,
2353 const FileLocation
*file
) const
2355 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2356 file
->relative_path
,
2357 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2361 MingwModuleHandler::GetSpecImplibDependencies (
2362 vector
<FileLocation
>& dependencies
,
2363 const FileLocation
*file
) const
2365 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2366 file
->relative_path
,
2367 GetBasename ( file
->name
) + "_" + module
.name
+ ".auto.def" ) );
2371 MingwModuleHandler::GetMcObjectDependencies (
2372 vector
<FileLocation
>& dependencies
,
2373 const FileLocation
*file
) const
2375 string basename
= GetBasename ( file
->name
);
2377 FileLocation
defDependency ( IntermediateDirectory
,
2380 dependencies
.push_back ( defDependency
);
2382 FileLocation
stubsDependency ( IntermediateDirectory
,
2383 file
->relative_path
,
2385 dependencies
.push_back ( stubsDependency
);
2389 MingwModuleHandler::GetWidlObjectDependencies (
2390 vector
<FileLocation
>& dependencies
,
2391 const FileLocation
*file
) const
2393 string basename
= GetBasename ( file
->name
);
2394 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2396 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2397 file
->relative_path
,
2398 basename
+ "_s.c" );
2399 dependencies
.push_back ( serverSourceDependency
);
2400 dependencies
.push_back ( *generatedHeaderFilename
);
2402 delete generatedHeaderFilename
;
2406 MingwModuleHandler::GetDefinitionDependencies (
2407 vector
<FileLocation
>& dependencies
) const
2409 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2410 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2412 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2413 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2414 string extension
= GetExtension ( sourceFile
);
2416 if (extension
== ".spec" || extension
== ".pspec")
2417 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2419 if (extension
== ".idl")
2421 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2422 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2427 enum DebugSupportType
2434 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2440 case DebugKernelMode
:
2441 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2445 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2452 module
.non_if_data
.libraries
.push_back(pLibrary
);
2456 MingwAddCRTLibrary( Module
&module
)
2458 const char * crtAttr
= module
.CRT
.c_str ();
2459 const char * crtLib
= NULL
;
2461 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2463 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2465 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2466 crtLib
= "libcntpr";
2467 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2472 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2474 if ( pLibrary
->importedModule
== NULL
)
2476 throw XMLInvalidBuildFileException (
2477 module
.node
.location
,
2478 "module '%s' trying to import non-existant C runtime module '%s'",
2479 module
.name
.c_str(),
2483 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2487 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2488 : MingwModuleHandler ( module_
)
2493 MingwBuildToolModuleHandler::Process ()
2495 GenerateBuildToolModuleTarget ();
2499 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2501 string
targetMacro ( GetTargetMacro (module
) );
2502 string objectsMacro
= GetObjectsMacro ( module
);
2503 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2504 string libsMacro
= GetLibsMacro ();
2508 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2511 if ( module
.cplusplus
)
2512 linker
= "${host_gpp}";
2514 linker
= "${host_gcc}";
2516 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2517 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2518 targetMacro
.c_str (),
2519 objectsMacro
.c_str (),
2520 linkDepsMacro
.c_str (),
2521 backend
->GetFullPath ( *target_file
).c_str () );
2522 fprintf ( fMakefile
, "\t$(ECHO_HOSTLD)\n" );
2523 fprintf ( fMakefile
,
2524 "\t%s %s -o $@ %s %s\n\n",
2526 GetLinkerMacro ().c_str (),
2527 objectsMacro
.c_str (),
2528 libsMacro
.c_str () );
2534 MingwKernelModuleHandler::MingwKernelModuleHandler (
2535 const Module
& module_
)
2537 : MingwModuleHandler ( module_
)
2542 MingwKernelModuleHandler::Process ()
2544 GenerateKernelModuleTarget ();
2548 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2550 string
targetMacro ( GetTargetMacro ( module
) );
2551 string workingDirectory
= GetWorkingDirectory ( );
2552 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2554 GenerateImportLibraryTargetIfNeeded ();
2556 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2560 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2562 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2563 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2564 module
.baseaddress
.c_str () );
2566 GenerateLinkerCommand ( dependencies
,
2567 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2572 GeneratePhonyTarget();
2577 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2578 const Module
& module_
)
2580 : MingwModuleHandler ( module_
)
2586 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2588 MingwAddCRTLibrary ( module
);
2589 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2593 MingwKernelModeDLLModuleHandler::Process ()
2595 GenerateKernelModeDLLModuleTarget ();
2599 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2601 string
targetMacro ( GetTargetMacro ( module
) );
2602 string workingDirectory
= GetWorkingDirectory ();
2603 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2605 GenerateImportLibraryTargetIfNeeded ();
2607 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2611 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2613 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2614 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2615 module
.baseaddress
.c_str () );
2616 GenerateLinkerCommand ( dependencies
,
2622 GeneratePhonyTarget();
2627 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2628 const Module
& module_
)
2630 : MingwModuleHandler ( module_
)
2635 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2637 MingwAddCRTLibrary ( module
);
2638 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2642 MingwNativeDLLModuleHandler::Process ()
2644 GenerateNativeDLLModuleTarget ();
2648 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2650 string
targetMacro ( GetTargetMacro (module
) );
2651 string workingDirectory
= GetWorkingDirectory ( );
2652 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2654 GenerateImportLibraryTargetIfNeeded ();
2656 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2660 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2662 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2663 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2664 module
.baseaddress
.c_str () );
2665 GenerateLinkerCommand ( dependencies
,
2671 GeneratePhonyTarget();
2676 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2677 const Module
& module_
)
2679 : MingwModuleHandler ( module_
)
2684 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2686 MingwAddCRTLibrary ( module
);
2687 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2691 MingwNativeCUIModuleHandler::Process ()
2693 GenerateNativeCUIModuleTarget ();
2697 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2699 string
targetMacro ( GetTargetMacro (module
) );
2700 string workingDirectory
= GetWorkingDirectory ( );
2701 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2703 GenerateImportLibraryTargetIfNeeded ();
2705 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2709 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2711 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2712 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2713 module
.baseaddress
.c_str () );
2714 GenerateLinkerCommand ( dependencies
,
2720 GeneratePhonyTarget();
2725 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2726 const Module
& module_
)
2728 : MingwModuleHandler ( module_
)
2732 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2733 const Module
& module_
)
2735 : MingwModuleHandler ( module_
)
2740 MingwAddImplicitLibraries( Module
&module
)
2744 if ( module
.type
!= Win32DLL
2745 && module
.type
!= Win32OCX
2746 && module
.type
!= Win32CUI
2747 && module
.type
!= Win32GUI
2748 && module
.type
!= Win32SCR
)
2753 if ( module
.isDefaultEntryPoint
)
2755 if ( module
.IsDLL () )
2757 //pLibrary = new Library ( module, "__mingw_dllmain" );
2758 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2762 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2763 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2767 pLibrary
= new Library ( module
, "mingw_common" );
2768 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2770 MingwAddCRTLibrary ( module
);
2771 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2775 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2777 MingwAddImplicitLibraries ( module
);
2781 MingwWin32DLLModuleHandler::Process ()
2783 GenerateWin32DLLModuleTarget ();
2787 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2789 string
targetMacro ( GetTargetMacro (module
) );
2790 string workingDirectory
= GetWorkingDirectory ( );
2791 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2793 GenerateImportLibraryTargetIfNeeded ();
2795 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2799 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2801 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2802 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2803 module
.baseaddress
.c_str () );
2804 GenerateLinkerCommand ( dependencies
,
2810 GeneratePhonyTarget();
2816 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2818 MingwAddImplicitLibraries ( module
);
2822 MingwWin32OCXModuleHandler::Process ()
2824 GenerateWin32OCXModuleTarget ();
2828 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2830 string
targetMacro ( GetTargetMacro (module
) );
2831 string workingDirectory
= GetWorkingDirectory ( );
2832 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2834 GenerateImportLibraryTargetIfNeeded ();
2836 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2840 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2842 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2843 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2844 module
.baseaddress
.c_str () );
2845 GenerateLinkerCommand ( dependencies
,
2851 GeneratePhonyTarget();
2856 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2857 const Module
& module_
)
2859 : MingwModuleHandler ( module_
)
2864 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2866 MingwAddImplicitLibraries ( module
);
2870 MingwWin32CUIModuleHandler::Process ()
2872 GenerateWin32CUIModuleTarget ();
2876 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2878 string
targetMacro ( GetTargetMacro (module
) );
2879 string workingDirectory
= GetWorkingDirectory ( );
2880 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2882 GenerateImportLibraryTargetIfNeeded ();
2884 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2888 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2890 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2891 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2892 module
.baseaddress
.c_str () );
2893 GenerateLinkerCommand ( dependencies
,
2899 GeneratePhonyTarget();
2904 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2905 const Module
& module_
)
2907 : MingwModuleHandler ( module_
)
2912 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2914 MingwAddImplicitLibraries ( module
);
2918 MingwWin32GUIModuleHandler::Process ()
2920 GenerateWin32GUIModuleTarget ();
2924 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2926 string
targetMacro ( GetTargetMacro (module
) );
2927 string workingDirectory
= GetWorkingDirectory ( );
2928 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2930 GenerateImportLibraryTargetIfNeeded ();
2932 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2936 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2938 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2939 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2940 module
.baseaddress
.c_str () );
2941 GenerateLinkerCommand ( dependencies
,
2947 GeneratePhonyTarget();
2952 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2953 const Module
& module_
)
2955 : MingwModuleHandler ( module_
)
2960 MingwBootLoaderModuleHandler::Process ()
2962 GenerateBootLoaderModuleTarget ();
2966 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2968 string
targetName ( module
.output
->name
);
2969 string
targetMacro ( GetTargetMacro (module
) );
2970 string workingDirectory
= GetWorkingDirectory ();
2971 FileLocation
junk_tmp ( TemporaryDirectory
,
2973 module
.name
+ ".junk.tmp" );
2974 CLEAN_FILE ( junk_tmp
);
2975 string objectsMacro
= GetObjectsMacro ( module
);
2976 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2980 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2982 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2983 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2984 targetMacro
.c_str (),
2985 objectsMacro
.c_str (),
2986 linkDepsMacro
.c_str (),
2987 backend
->GetFullPath ( *target_file
).c_str () );
2989 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2991 if (Environment::GetArch() == "arm")
2993 fprintf ( fMakefile
,
2994 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
2995 backend
->GetFullName ( junk_tmp
).c_str (),
2996 objectsMacro
.c_str (),
2997 linkDepsMacro
.c_str (),
2998 GetLinkerMacro ().c_str ());
3002 fprintf ( fMakefile
,
3003 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
3004 backend
->GetFullName ( junk_tmp
).c_str (),
3005 objectsMacro
.c_str (),
3006 linkDepsMacro
.c_str (),
3007 GetLinkerMacro ().c_str ());
3009 fprintf ( fMakefile
,
3010 "\t${objcopy} -O binary %s $@\n",
3011 backend
->GetFullName ( junk_tmp
).c_str () );
3012 GenerateBuildMapCode ( &junk_tmp
);
3013 fprintf ( fMakefile
,
3014 "\t-@${rm} %s 2>$(NUL)\n",
3015 backend
->GetFullName ( junk_tmp
).c_str () );
3021 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
3022 const Module
& module_
)
3023 : MingwModuleHandler ( module_
)
3028 MingwBootProgramModuleHandler::Process ()
3030 GenerateBootProgramModuleTarget ();
3034 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3036 string
targetName ( module
.output
->name
);
3037 string
targetMacro ( GetTargetMacro (module
) );
3038 string workingDirectory
= GetWorkingDirectory ();
3039 FileLocation
junk_tmp ( TemporaryDirectory
,
3041 module
.name
+ ".junk.tmp" );
3042 FileLocation
junk_elf ( TemporaryDirectory
,
3044 module
.name
+ ".junk.elf" );
3045 FileLocation
junk_cpy ( TemporaryDirectory
,
3047 module
.name
+ ".junk.elf" );
3048 CLEAN_FILE ( junk_tmp
);
3049 CLEAN_FILE ( junk_elf
);
3050 CLEAN_FILE ( junk_cpy
);
3051 string objectsMacro
= GetObjectsMacro ( module
);
3052 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3053 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3057 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
3059 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3060 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3061 targetMacro
.c_str (),
3062 objectsMacro
.c_str (),
3063 linkDepsMacro
.c_str (),
3064 payload
->name
.c_str (),
3065 backend
->GetFullPath ( *target_file
).c_str () );
3067 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3069 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3070 module
.buildtype
.c_str (),
3071 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3072 backend
->GetFullName ( junk_cpy
).c_str () );
3074 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3075 module
.buildtype
.c_str (),
3076 backend
->GetFullName ( junk_cpy
).c_str (),
3077 backend
->GetFullName ( junk_tmp
).c_str () );
3079 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
3080 module
.buildtype
.c_str (),
3081 linkDepsMacro
.c_str (),
3082 backend
->GetFullName ( junk_tmp
).c_str (),
3083 backend
->GetFullName ( junk_elf
).c_str () );
3085 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3086 module
.buildtype
.c_str (),
3087 backend
->GetFullName ( junk_elf
).c_str (),
3088 backend
->GetFullName ( *module
.output
) .c_str () );
3090 fprintf ( fMakefile
,
3091 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3092 backend
->GetFullName ( junk_tmp
).c_str (),
3093 backend
->GetFullName ( junk_elf
).c_str (),
3094 backend
->GetFullName ( junk_cpy
).c_str () );
3100 MingwIsoModuleHandler::MingwIsoModuleHandler (
3101 const Module
& module_
)
3103 : MingwModuleHandler ( module_
)
3108 MingwIsoModuleHandler::Process ()
3110 GenerateIsoModuleTarget ();
3114 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3115 const string
& bootcdDirectory
)
3117 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3119 const Module
& m
= *p
->second
;
3122 if ( m
.bootstrap
!= NULL
)
3124 FileLocation
targetFile ( OutputDirectory
,
3125 m
.bootstrap
->base
.length () > 0
3126 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3128 m
.bootstrap
->nameoncd
);
3129 OutputCopyCommand ( *m
.output
, targetFile
);
3135 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3136 const string
& bootcdDirectory
)
3138 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3140 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3141 FileLocation
targetFile ( OutputDirectory
,
3142 cdfile
.target
->relative_path
.length () > 0
3143 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3145 cdfile
.target
->name
);
3146 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3151 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3152 const string
& bootcdDirectory
)
3154 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3156 const Module
& m
= *p
->second
;
3159 if ( m
.bootstrap
!= NULL
)
3161 FileLocation
targetDirectory ( OutputDirectory
,
3162 m
.bootstrap
->base
.length () > 0
3163 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3166 out
.push_back ( targetDirectory
);
3172 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3173 const string
& bootcdDirectory
)
3175 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3177 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3178 FileLocation
targetDirectory ( OutputDirectory
,
3179 cdfile
.target
->relative_path
.length () > 0
3180 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3183 out
.push_back( targetDirectory
);
3188 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3189 const string
& bootcdDirectory
)
3191 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3192 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3196 MingwIsoModuleHandler::GetBootstrapCdFiles (
3197 vector
<FileLocation
>& out
) const
3199 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3201 const Module
& m
= *p
->second
;
3204 if ( m
.bootstrap
!= NULL
)
3206 out
.push_back ( *m
.output
);
3212 MingwIsoModuleHandler::GetNonModuleCdFiles (
3213 vector
<FileLocation
>& out
) const
3215 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3217 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3218 out
.push_back ( *cdfile
.source
);
3223 MingwIsoModuleHandler::GetCdFiles (
3224 vector
<FileLocation
>& out
) const
3226 GetBootstrapCdFiles ( out
);
3227 GetNonModuleCdFiles ( out
);
3231 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3233 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
3234 string bootcdDirectory
= "cd";
3235 FileLocation
bootcd ( OutputDirectory
,
3238 FileLocation
bootcdReactos ( OutputDirectory
,
3239 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3241 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3242 vector
<FileLocation
> vCdDirectories
;
3245 FileLocation
srcunattend ( SourceDirectory
,
3246 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3248 FileLocation
tarunattend ( bootcdReactos
.directory
,
3249 bootcdReactos
.relative_path
,
3251 if (module
.type
== IsoRegTest
)
3252 vSourceFiles
.push_back ( srcunattend
);
3255 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3259 throw InvalidOperationException ( module
.node
.location
.c_str(),
3261 "Invalid bootsector. module '%s' requires <bootsector>",
3262 module
.name
.c_str ());
3265 const FileLocation
*isoboot
= bootModule
->output
;
3266 vSourceFiles
.push_back ( *isoboot
);
3268 // prepare reactos.dff and reactos.inf
3269 FileLocation
reactosDff ( SourceDirectory
,
3270 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3272 FileLocation
reactosInf ( bootcdReactos
.directory
,
3273 bootcdReactos
.relative_path
,
3276 vSourceFiles
.push_back ( reactosDff
);
3279 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3280 Iso/LiveIso outputs are generated in code base root
3282 string IsoName
= module
.output
->name
;
3284 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3287 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3288 GetCdFiles ( vCdFiles
);
3289 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3290 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3292 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3293 module
.name
.c_str ());
3294 fprintf ( fMakefile
,
3295 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3296 module
.name
.c_str (),
3297 backend
->GetFullName ( *isoboot
).c_str (),
3298 sourceFiles
.c_str (),
3300 cdDirectories
.c_str () );
3301 fprintf ( fMakefile
,
3302 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3303 backend
->GetFullName ( reactosDff
).c_str (),
3304 backend
->GetFullPath ( bootcdReactos
).c_str () );
3305 fprintf ( fMakefile
,
3306 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3307 backend
->GetFullName ( reactosDff
).c_str (),
3308 backend
->GetFullName ( reactosInf
).c_str (),
3309 backend
->GetFullPath ( bootcdReactos
).c_str ());
3310 fprintf ( fMakefile
,
3311 "\t-@${rm} %s 2>$(NUL)\n",
3312 backend
->GetFullName ( reactosInf
).c_str () );
3313 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3314 OutputCdfileCopyCommands ( bootcdDirectory
);
3316 if (module
.type
== IsoRegTest
)
3317 OutputCopyCommand ( srcunattend
, tarunattend
);
3319 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3320 fprintf ( fMakefile
,
3321 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3322 backend
->GetFullName ( *isoboot
).c_str (),
3323 backend
->GetFullPath ( bootcd
).c_str (),
3325 fprintf ( fMakefile
,
3330 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3331 const Module
& module_
)
3333 : MingwModuleHandler ( module_
)
3338 MingwLiveIsoModuleHandler::Process ()
3340 GenerateLiveIsoModuleTarget ();
3344 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3346 FileLocation
dir ( OutputDirectory
,
3349 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3353 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3354 string
& reactosDirectory
)
3356 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3358 const Module
& m
= *p
->second
;
3363 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3364 FileLocation
destination ( OutputDirectory
,
3365 m
.install
->relative_path
.length () > 0
3366 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3367 : livecdDirectory
+ sSep
+ reactosDirectory
,
3369 OutputCopyCommand ( *aliasedModule
.output
,
3376 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3377 string
& reactosDirectory
)
3379 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3381 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3382 FileLocation
target ( OutputDirectory
,
3383 installfile
.target
->relative_path
.length () > 0
3384 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3385 : livecdDirectory
+ sSep
+ reactosDirectory
,
3386 installfile
.target
->name
);
3387 OutputCopyCommand ( *installfile
.source
, target
);
3392 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3394 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3395 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3396 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3397 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3398 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3399 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3401 FileLocation
livecdIni ( SourceDirectory
,
3402 "boot" + sSep
+ "bootdata",
3404 FileLocation
destination ( OutputDirectory
,
3407 OutputCopyCommand ( livecdIni
,
3412 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3414 FileLocation
freeldr ( OutputDirectory
,
3415 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3417 FileLocation
destination ( OutputDirectory
,
3418 livecdDirectory
+ sSep
+ "loader",
3420 OutputCopyCommand ( freeldr
,
3425 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3427 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
3428 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3429 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3431 fprintf ( fMakefile
,
3432 "\t$(ECHO_MKHIVE)\n" );
3433 fprintf ( fMakefile
,
3434 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3435 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3436 cSep
, cSep
, cSep
, cSep
);
3440 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3442 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3443 string livecdDirectory
= module
.name
;
3444 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3449 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3453 throw InvalidOperationException ( module
.node
.location
.c_str(),
3455 "Invalid bootsector. module '%s' requires <bootsector>",
3456 module
.name
.c_str ());
3459 const FileLocation
*isoboot
= bootModule
->output
;
3462 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3463 Iso/LiveIso outputs are generated in code base root
3465 IsoName
= module
.output
->name
;
3467 string reactosDirectory
= "reactos";
3468 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3469 FileLocation
livecdReactos ( OutputDirectory
,
3470 livecdReactosNoFixup
,
3472 CLEAN_FILE ( livecdReactos
);
3474 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3475 module
.name
.c_str ());
3476 fprintf ( fMakefile
,
3477 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3478 module
.name
.c_str (),
3479 backend
->GetFullName ( *isoboot
) .c_str (),
3480 backend
->GetFullPath ( livecdReactos
).c_str () );
3481 OutputModuleCopyCommands ( livecdDirectory
,
3483 OutputNonModuleCopyCommands ( livecdDirectory
,
3485 OutputProfilesDirectoryCommands ( livecdDirectory
);
3486 OutputLoaderCommands ( livecdDirectory
);
3487 OutputRegistryCommands ( livecdDirectory
);
3488 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3489 fprintf ( fMakefile
,
3490 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3491 backend
->GetFullName( *isoboot
).c_str (),
3492 backend
->GetFullPath ( livecd
).c_str (),
3494 fprintf ( fMakefile
,
3499 MingwTestModuleHandler::MingwTestModuleHandler (
3500 const Module
& module_
)
3502 : MingwModuleHandler ( module_
)
3507 MingwTestModuleHandler::Process ()
3509 GenerateTestModuleTarget ();
3512 /* caller needs to delete the returned object */
3514 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3516 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3517 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3518 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3522 MingwTestModuleHandler::GenerateTestModuleTarget ()
3524 string
targetMacro ( GetTargetMacro ( module
) );
3525 string workingDirectory
= GetWorkingDirectory ( );
3526 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3528 GenerateImportLibraryTargetIfNeeded ();
3530 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3534 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3536 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3537 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3538 module
.baseaddress
.c_str () );
3539 GenerateLinkerCommand ( dependencies
,
3545 GeneratePhonyTarget();
3550 MingwAliasModuleHandler::MingwAliasModuleHandler (
3551 const Module
& module_
)
3553 : MingwModuleHandler ( module_
)
3558 MingwAliasModuleHandler::Process ()
3563 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3564 const Module
& module_
)
3566 : MingwModuleHandler ( module_
)
3571 MingwCabinetModuleHandler::Process ()
3573 string
targetMacro ( GetTargetMacro (module
) );
3577 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3578 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3579 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3580 targetMacro
.c_str (),
3581 backend
->GetFullPath ( *target_file
).c_str () );
3583 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3584 fprintf ( fMakefile
,
3585 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3586 targetMacro
.c_str (),
3587 module
.name
.c_str());
3590 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3591 const Module
& module_
)
3593 : MingwModuleHandler ( module_
)
3598 MingwElfExecutableModuleHandler::Process ()
3600 string
targetName ( module
.output
->name
);
3601 string
targetMacro ( GetTargetMacro (module
) );
3602 string workingDirectory
= GetWorkingDirectory ();
3603 string objectsMacro
= GetObjectsMacro ( module
);
3604 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3605 string libsMacro
= GetLibsMacro ();
3609 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3610 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3611 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3612 targetMacro
.c_str (),
3613 objectsMacro
.c_str (),
3614 linkDepsMacro
.c_str (),
3615 backend
->GetFullPath ( *target_file
).c_str () );
3617 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3619 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -gstabs+ -o %s\n",
3620 module
.buildtype
.c_str(),
3621 objectsMacro
.c_str(),
3623 targetMacro
.c_str () );