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 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
782 if ( deps
.size () > 0 )
795 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
797 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
798 delete compilationUnits
[i
];
802 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
807 MingwModuleHandler::GenerateSourceMacros (
808 const IfableData
& data
)
812 fprintf ( fMakefile
, "# SOURCE MACROS\n" );
813 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
814 vector
<const FileLocation
*> headers
;
815 if ( compilationUnits
.size () > 0 )
820 sourcesMacro
.c_str () );
821 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
823 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
824 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
828 ( i
%10 == 9 ? " \\\n\t" : " " ),
829 backend
->GetFullName ( compilationName
).c_str () );
831 fprintf ( fMakefile
, "\n" );
834 vector
<CompilationUnit
*> sourceCompilationUnits
;
835 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
836 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
838 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
842 sourcesMacro
.c_str(),
843 backend
->GetFullName ( compilationName
).c_str () );
845 CleanupCompilationUnitVector ( sourceCompilationUnits
);
849 MingwModuleHandler::GenerateObjectMacros (
850 const IfableData
& data
)
853 const char* assignmentOperation
= "=";
855 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
856 vector
<const FileLocation
*> headers
;
857 vector
<const FileLocation
*> mcheaders
;
858 vector
<const FileLocation
*> mcresources
;
859 fprintf ( fMakefile
, "# OBJECT MACROS\n" );
860 if ( compilationUnits
.size () > 0 )
862 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
864 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
865 if ( compilationUnit
.IsFirstFile () )
867 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
868 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
871 objectsMacro
.c_str(),
872 backend
->GetFullName ( *object_file
).c_str () );
874 assignmentOperation
= "+=";
881 objectsMacro
.c_str (),
882 assignmentOperation
);
883 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
885 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
886 if ( !compilationUnit
.IsFirstFile () )
888 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
889 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
890 if ( GetExtension ( *objectFilename
) == ".h" )
891 headers
.push_back ( objectFilename
);
892 else if ( GetExtension ( *objectFilename
) == ".rc" )
894 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
895 mcheaders
.push_back ( headerFilename
);
896 mcresources
.push_back ( objectFilename
);
903 ( i
%10 == 9 ? " \\\n\t" : " " ),
904 backend
->GetFullName ( *objectFilename
).c_str () );
905 delete objectFilename
;
909 fprintf ( fMakefile
, "\n" );
911 if ( headers
.size () > 0 )
916 module
.name
.c_str (),
917 assignmentOperation
);
918 for ( i
= 0; i
< headers
.size (); i
++ )
923 ( i
%10 == 9 ? " \\\n\t" : " " ),
924 backend
->GetFullName ( *headers
[i
] ).c_str () );
927 fprintf ( fMakefile
, "\n" );
930 if ( mcheaders
.size () > 0 )
935 module
.name
.c_str (),
936 assignmentOperation
);
937 for ( i
= 0; i
< mcheaders
.size (); i
++ )
942 ( i
%10 == 9 ? " \\\n\t" : " " ),
943 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
946 fprintf ( fMakefile
, "\n" );
949 if ( mcresources
.size () > 0 )
954 module
.name
.c_str (),
955 assignmentOperation
);
956 for ( i
= 0; i
< mcresources
.size (); i
++ )
961 ( i
%10 == 9 ? " \\\n\t" : " " ),
962 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
963 delete mcresources
[i
];
965 fprintf ( fMakefile
, "\n" );
968 vector
<CompilationUnit
*> sourceCompilationUnits
;
969 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
970 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
972 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
973 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
977 objectsMacro
.c_str(),
978 backend
->GetFullName ( *object_file
).c_str () );
981 CleanupCompilationUnitVector ( sourceCompilationUnits
);
983 if ( IsSpecDefinitionFile() )
985 const FileLocation
*stubs_file
= new FileLocation(
986 IntermediateDirectory
,
987 module
.importLibrary
->source
->relative_path
,
988 ReplaceExtension ( module
.importLibrary
->source
->name
, "_" + module
.name
+ ".stubs.o" ) );
993 objectsMacro
.c_str(),
994 backend
->GetFullName ( *stubs_file
).c_str () );
1000 /* caller needs to delete the returned object */
1002 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1004 if ( !module
.pch
|| !use_pch
)
1006 return new FileLocation ( IntermediateDirectory
,
1007 module
.pch
->file
->relative_path
+ "/.gch_" + module
.name
,
1008 module
.pch
->file
->name
+ ".gch" );
1011 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) $(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1012 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1013 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1014 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1015 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1017 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1018 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1020 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1021 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1023 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1024 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1025 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1026 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1027 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1029 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1030 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1031 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1032 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1034 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1035 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1036 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1037 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1038 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1040 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1041 "\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"
1042 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1043 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1044 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1045 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1046 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1047 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"
1049 "\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",
1050 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1051 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1052 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1053 Rule
winebuildPDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1055 "\t${gcc} -xc -E ${$(module_name)_RCFLAGS} $(source) > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec\n\n"
1056 "$(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"
1057 "\t$(ECHO_WINEBLD)\n"
1058 "\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",
1059 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec",
1060 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1061 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1062 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"
1063 "\t$(ECHO_WINEBLD)\n"
1064 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec --filename $(module_dllname)\n\n"
1065 "$(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"
1067 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1068 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec",
1069 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1070 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1071 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1072 Rule
winebuildDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1073 "\t$(ECHO_WINEBLD)\n"
1074 "\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",
1075 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
1076 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1077 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1078 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1079 "\t$(ECHO_WINEBLD)\n"
1080 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(source_path)$(SEP)$(source_name_noext).spec --filename $(module_dllname)\n"
1081 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1083 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1084 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1085 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1086 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1087 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1088 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1090 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1091 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1092 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1093 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1094 "$(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"
1096 "\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"
1097 "$(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"
1099 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1100 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1101 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1102 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1103 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1104 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1105 "$(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"
1107 "\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"
1108 "$(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"
1110 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1111 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1112 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1113 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1114 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1115 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1116 "$(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"
1118 "\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"
1119 "$(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"
1121 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1122 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1123 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1124 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1125 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1126 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1127 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1129 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1130 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1131 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1132 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1134 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1135 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1136 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1137 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1139 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1140 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1141 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1142 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1144 "\t${gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1145 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1146 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1147 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1149 "\t${host_gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1150 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1151 Rule
emptyRule ( "", NULL
);
1154 MingwModuleHandler::GenerateGccCommand (
1155 const FileLocation
* sourceFile
,
1157 const string
& extraDependencies
)
1159 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1160 string dependencies
= extraDependencies
;
1163 string extension
= GetExtension ( *sourceFile
);
1164 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1165 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1167 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1171 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1175 /* WIDL generated headers may be used */
1176 vector
<FileLocation
> rpcDependencies
;
1177 GetRpcHeaderDependencies ( rpcDependencies
);
1178 if ( rpcDependencies
.size () > 0 )
1179 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1181 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1185 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1187 const Property
* property
= module
.project
.LookupProperty(name
);
1190 return property
->value
;
1192 return string ( "" );
1195 /* caller needs to delete the returned object */
1197 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1199 string newname
= GetBasename ( base
->name
) + "_s.h";
1200 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1203 /* caller needs to delete the returned object */
1205 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1207 string newname
= GetBasename ( base
->name
) + "_c.h";
1208 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1211 /* caller needs to delete the returned object */
1213 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1215 string newname
= GetBasename ( base
->name
) + "_p.h";
1216 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1219 /* caller needs to delete the returned object */
1221 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1223 string newname
= GetBasename ( base
->name
) + ".h";
1224 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1227 /* caller needs to delete the returned object */
1229 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1231 string newname
= GetBasename ( base
->name
) + ".h";
1232 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1236 MingwModuleHandler::GenerateCommands (
1237 const CompilationUnit
& compilationUnit
,
1238 const string
& extraDependencies
)
1240 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1241 string extension
= GetExtension ( sourceFile
);
1242 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1251 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1252 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1253 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1254 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1255 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1256 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1257 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1258 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1259 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1260 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1261 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1262 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1263 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1264 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1265 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1266 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1267 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1268 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1269 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1272 Rule
*customRule
= NULL
;
1274 fprintf ( fMakefile
, "# COMMANDS\n" );
1276 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1278 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1280 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1282 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1284 customRule
= rules
[i
].rule
;
1288 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1290 GenerateGccCommand ( &sourceFile
,
1292 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1294 else if ( customRule
)
1295 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1298 throw InvalidOperationException ( __FILE__
,
1300 "Unsupported filename extension '%s' in file '%s'",
1302 backend
->GetFullName ( sourceFile
).c_str () );
1307 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1309 fprintf ( fMakefile
, "# BUILD MAP CODE\n" );
1311 fprintf ( fMakefile
,
1312 "ifeq ($(ROS_BUILDMAP),full)\n" );
1314 FileLocation
mapFilename ( OutputDirectory
,
1315 module
.output
->relative_path
,
1316 GetBasename ( module
.output
->name
) + ".map" );
1317 CLEAN_FILE ( mapFilename
);
1319 fprintf ( fMakefile
,
1320 "\t$(ECHO_OBJDUMP)\n" );
1321 fprintf ( fMakefile
,
1322 "\t$(Q)${objdump} -d -S %s > %s\n",
1323 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1324 backend
->GetFullName ( mapFilename
).c_str () );
1326 fprintf ( fMakefile
,
1328 fprintf ( fMakefile
,
1329 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1331 fprintf ( fMakefile
,
1333 fprintf ( fMakefile
,
1334 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1335 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1336 backend
->GetFullName ( mapFilename
).c_str () );
1338 fprintf ( fMakefile
,
1341 fprintf ( fMakefile
,
1346 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1348 fprintf ( fMakefile
, "# BUILD NO STRIP CODE\n" );
1350 fprintf ( fMakefile
,
1351 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1353 FileLocation
nostripFilename ( OutputDirectory
,
1354 module
.output
->relative_path
,
1355 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1356 CLEAN_FILE ( nostripFilename
);
1358 OutputCopyCommand ( *module
.output
, nostripFilename
);
1360 fprintf ( fMakefile
,
1365 MergeStringVector ( const Backend
* backend
,
1366 const vector
<FileLocation
>& input
,
1367 vector
<string
>& output
)
1371 int wrap_count
= -1;
1372 for ( size_t i
= 0; i
< input
.size (); i
++ )
1374 if ( wrap_count
++ == wrap_at
)
1376 output
.push_back ( s
);
1380 else if ( s
.size () > 0)
1382 s
+= backend
->GetFullName ( input
[i
] );
1384 if ( s
.length () > 0 )
1385 output
.push_back ( s
);
1389 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1390 vector
<FileLocation
>& objectFiles
) const
1392 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1394 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1395 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1396 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1397 objectFiles
.push_back ( *object_file
);
1403 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1405 if ( backend
->configuration
.CleanAsYouGo
)
1407 vector
<FileLocation
> objectFiles
;
1408 GetObjectsVector ( module
.non_if_data
,
1410 vector
<string
> lines
;
1411 MergeStringVector ( backend
,
1414 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1416 fprintf ( fMakefile
,
1417 "\t-@${rm} %s 2>$(NUL)\n",
1418 lines
[i
].c_str () );
1424 MingwModuleHandler::GenerateRunRsymCode () const
1426 fprintf ( fMakefile
, "# RUN RSYM CODE\n" );
1427 fprintf ( fMakefile
,
1428 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1429 fprintf ( fMakefile
,
1430 "\t$(ECHO_RSYM)\n" );
1431 fprintf ( fMakefile
,
1432 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1433 fprintf ( fMakefile
,
1438 MingwModuleHandler::GenerateRunStripCode () const
1440 fprintf ( fMakefile
, "# RUN STRIP CODE\n" );
1441 fprintf ( fMakefile
,
1442 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1443 fprintf ( fMakefile
,
1444 "\t$(ECHO_STRIP)\n" );
1445 fprintf ( fMakefile
,
1446 "\t${strip} -s -x -X $@\n\n" );
1447 fprintf ( fMakefile
,
1452 MingwModuleHandler::GenerateLinkerCommand (
1453 const string
& dependencies
,
1454 const string
& linkerParameters
,
1455 const string
& pefixupParameters
)
1457 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1458 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1459 string linker
= "${ld}";
1460 string objectsMacro
= GetObjectsMacro ( module
);
1461 string libsMacro
= GetLibsMacro ();
1463 fprintf ( fMakefile
, "# LINKER COMMAND\n" );
1465 string
target_macro ( GetTargetMacro ( module
) );
1466 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1468 string linkerScriptArgument
;
1469 if ( module
.linkerScript
!= NULL
)
1470 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1472 linkerScriptArgument
= "";
1474 /* check if we need to add default C++ libraries, ie if we have
1475 * a C++ user-mode module without the -nostdlib linker flag
1477 bool link_defaultlibs
= module
.cplusplus
&&
1478 linkerParameters
.find ("-nostdlib") == string::npos
&&
1479 !(module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
);
1481 if ( !module
.HasImportLibrary() )
1483 fprintf ( fMakefile
,
1484 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1485 target_macro
.c_str (),
1486 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1487 dependencies
.c_str (),
1488 target_folder
.c_str () );
1489 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1491 fprintf ( fMakefile
,
1492 "\t%s %s%s %s %s %s %s -o %s\n",
1494 linkerParameters
.c_str (),
1495 linkerScriptArgument
.c_str (),
1496 objectsMacro
.c_str (),
1497 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1499 GetLinkerMacro ().c_str (),
1500 target_macro
.c_str () );
1504 FileLocation
temp_exp ( IntermediateDirectory
,
1505 module
.output
->relative_path
,
1506 module
.name
+ ".exp" );
1507 CLEAN_FILE ( temp_exp
);
1509 fprintf ( fMakefile
,
1511 backend
->GetFullName ( temp_exp
).c_str (),
1512 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1513 backend
->GetFullPath ( temp_exp
).c_str () );
1514 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1516 fprintf ( fMakefile
,
1517 "\t${dlltool} --dllname %s --def %s --output-exp $@%s%s\n",
1518 module
.GetDllName ().c_str (),
1519 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1520 module
.mangledSymbols
? "" : " --kill-at",
1521 module
.underscoreSymbols
? " --add-underscore" : "" );
1523 fprintf ( fMakefile
,
1524 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1525 target_macro
.c_str (),
1526 backend
->GetFullName ( temp_exp
).c_str (),
1527 dependencies
.c_str (),
1528 target_folder
.c_str () );
1529 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1531 fprintf ( fMakefile
,
1532 "\t%s %s%s %s %s %s %s %s -o %s\n",
1535 linkerParameters
.c_str (),
1536 linkerScriptArgument
.c_str (),
1537 backend
->GetFullName ( temp_exp
).c_str (),
1538 objectsMacro
.c_str (),
1539 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1541 GetLinkerMacro ().c_str (),
1542 target_macro
.c_str () );
1544 fprintf ( fMakefile
,
1545 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1546 target_macro
.c_str (),
1547 pefixupParameters
.c_str() );
1550 GenerateBuildMapCode ();
1551 GenerateBuildNonSymbolStrippedCode ();
1552 GenerateRunRsymCode ();
1553 GenerateRunStripCode ();
1554 GenerateCleanObjectsAsYouGoCode ();
1556 if ( definitionFilename
)
1557 delete definitionFilename
;
1562 MingwModuleHandler::GeneratePhonyTarget() const
1564 string
targetMacro ( GetTargetMacro ( module
) );
1565 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1567 fprintf ( fMakefile
, "# PHONY TARGET\n" );
1568 fprintf ( fMakefile
,
1570 targetMacro
.c_str ());
1571 fprintf ( fMakefile
, "%s: | %s\n",
1572 targetMacro
.c_str (),
1573 backend
->GetFullPath ( *target_file
).c_str () );
1579 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1582 string moduleDependencies
;
1584 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1586 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1587 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1589 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1590 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1591 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1592 if ( GetExtension ( *objectFilename
) == ".h" )
1593 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1594 else if ( GetExtension ( *objectFilename
) == ".rc" )
1595 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1596 delete objectFilename
;
1599 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1601 GenerateCommands ( *compilationUnits
[i
],
1602 moduleDependencies
);
1603 fprintf ( fMakefile
,
1607 vector
<CompilationUnit
*> sourceCompilationUnits
;
1608 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1609 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1611 GenerateCommands ( *sourceCompilationUnits
[i
],
1612 moduleDependencies
);
1614 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1616 SpecFileType spec
= IsSpecDefinitionFile ();
1623 defRule
= &winebuildPRule
;
1625 defRule
= &winebuildRule
;
1627 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
1632 MingwModuleHandler::GenerateObjectFileTargets ()
1634 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1636 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1640 string cc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gcc}" : "${gcc}" );
1641 string cppc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gpp}" : "${gpp}" );
1643 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1644 CLEAN_FILE ( *pchFilename
);
1645 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1646 /* WIDL generated headers may be used */
1647 vector
<FileLocation
> rpcDependencies
;
1648 GetRpcHeaderDependencies ( rpcDependencies
);
1649 if ( rpcDependencies
.size () > 0 )
1650 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1651 fprintf ( fMakefile
,
1653 backend
->GetFullName ( *pchFilename
).c_str(),
1654 dependencies
.c_str(),
1655 backend
->GetFullPath ( *pchFilename
).c_str() );
1656 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1657 fprintf ( fMakefile
,
1658 "\t%s -o %s %s %s -gstabs+ %s\n\n",
1659 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1660 backend
->GetFullName ( *pchFilename
).c_str(),
1661 module
.cplusplus
? cxxflagsMacro
.c_str() : cflagsMacro
.c_str(),
1662 GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, module
.cplusplus
? CompilerTypeCPP
: CompilerTypeCC
).c_str(),
1663 backend
->GetFullName ( baseHeaderFile
).c_str() );
1667 GenerateObjectFileTargets ( module
.non_if_data
);
1668 fprintf ( fMakefile
, "\n" );
1671 /* caller needs to delete the returned object */
1673 MingwModuleHandler::GenerateArchiveTarget ()
1675 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1676 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1678 fprintf ( fMakefile
, "# ARCHIVE TARGET\n" );
1680 if ( IsStaticLibrary ( module
) && definitionFilename
)
1682 arRule1
.Execute ( fMakefile
,
1687 backend
->GetFullName ( *definitionFilename
).c_str () );
1689 fprintf ( fMakefile
,
1690 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1691 module
.GetDllName ().c_str (),
1692 backend
->GetFullName ( *definitionFilename
).c_str (),
1693 module
.mangledSymbols
? "" : " --kill-at",
1694 module
.underscoreSymbols
? " --add-underscore" : "" );
1697 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1699 if ( definitionFilename
)
1700 delete definitionFilename
;
1702 if(module
.type
== HostStaticLibrary
)
1703 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1705 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1707 GenerateCleanObjectsAsYouGoCode ();
1709 fprintf ( fMakefile
, "\n" );
1711 return archiveFilename
;
1715 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1717 return ssprintf ( "$(%s_OBJS)",
1718 module
.name
.c_str () );
1722 MingwModuleHandler::GetLinkingDependenciesMacro () const
1724 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1728 MingwModuleHandler::GetLibsMacro () const
1730 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1734 MingwModuleHandler::GetLinkerMacro () const
1736 return ssprintf ( "$(%s_LFLAGS)",
1737 module
.name
.c_str () );
1741 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1743 if ( ReferenceObjects ( module
) )
1744 return GetObjectsMacro ( module
);
1747 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1748 string target
= backend
->GetFullName ( *target_file
).c_str ();
1755 MingwModuleHandler::GenerateSourceMacro ()
1757 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1759 GenerateSourceMacros ( module
.non_if_data
);
1761 // future references to the macro will be to get its values
1762 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1766 MingwModuleHandler::GenerateObjectMacro ()
1768 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1770 GenerateObjectMacros ( module
.non_if_data
);
1772 // future references to the macro will be to get its values
1773 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1777 MingwModuleHandler::GenerateTargetMacro ()
1779 fprintf ( fMakefile
, "# TARGET MACRO\n" );
1780 fprintf ( fMakefile
,
1782 GetTargetMacro ( module
, false ).c_str (),
1783 GetModuleTargets ( module
).c_str () );
1787 MingwModuleHandler::GetRpcHeaderDependencies (
1788 vector
<FileLocation
>& dependencies
) const
1790 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1792 Library
& library
= *module
.non_if_data
.libraries
[i
];
1793 if ( library
.importedModule
->type
== RpcServer
||
1794 library
.importedModule
->type
== RpcClient
||
1795 library
.importedModule
->type
== RpcProxy
||
1796 library
.importedModule
->type
== IdlHeader
)
1798 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1800 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1801 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1802 string extension
= GetExtension ( sourceFile
);
1803 if ( extension
== ".idl" || extension
== ".IDL" )
1805 string basename
= GetBasename ( sourceFile
.name
);
1806 if ( library
.importedModule
->type
== RpcServer
)
1808 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1809 dependencies
.push_back ( *header
);
1812 if ( library
.importedModule
->type
== RpcClient
)
1814 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1815 dependencies
.push_back ( *header
);
1818 if ( library
.importedModule
->type
== RpcProxy
)
1820 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1821 dependencies
.push_back ( *header
);
1824 if ( library
.importedModule
->type
== IdlHeader
)
1826 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1827 dependencies
.push_back ( *header
);
1837 MingwModuleHandler::GenerateOtherMacros ()
1839 set
<const Define
*> used_defs
;
1841 fprintf ( fMakefile
, "# OTHER MACROS\n" );
1843 commonflagsMacro
= ssprintf ("%s_COMMONFLAGS", module
.name
.c_str ());
1844 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1845 cxxflagsMacro
= ssprintf ("%s_CXXFLAGS", module
.name
.c_str ());
1846 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1847 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1848 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1849 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1850 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1851 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1856 &module
.linkerFlags
,
1859 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1861 GenerateMacros("+=", module
.project
.host_non_if_data
, NULL
, used_defs
);
1867 module
.project
.non_if_data
,
1872 if ( IsSpecDefinitionFile() )
1874 vector
<FileLocation
> s
;
1875 GetSpecImplibDependencies ( s
, module
.importLibrary
->source
);
1880 linkDepsMacro
.c_str() );
1881 for ( size_t i
= 0; i
< s
.size(); i
++ )
1882 fprintf ( fMakefile
,
1884 backend
->GetFullName ( s
[i
] ).c_str () );
1885 fprintf ( fMakefile
, "\n" );
1888 string globalCflags
= " ";
1889 globalCflags
+= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
1890 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1892 if ( module
.dynamicCRT
)
1893 globalCflags
+= " -D_DLL -D__USE_CRTIMP";
1896 globalCflags
+= " -Wall -Wpointer-arith";
1897 globalCflags
+= " -gstabs+";
1898 if ( backend
->usePipe
)
1899 globalCflags
+= " -pipe";
1900 if ( !module
.allowWarnings
)
1901 globalCflags
+= " -Werror";
1902 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1904 if ( module
.cplusplus
)
1905 globalCflags
+= " $(HOST_CPPFLAGS)";
1907 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
1911 if ( module
.cplusplus
)
1913 globalCflags
+= " $(TARGET_CPPFLAGS)";
1916 globalCflags
+= " -nostdinc";
1919 // Always force disabling of sibling calls optimisation for GCC
1920 // (TODO: Move to version-specific once this bug is fixed in GCC)
1921 globalCflags
+= " -fno-optimize-sibling-calls";
1923 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1928 cflagsMacro
.c_str (),
1929 (" $(PROJECT_CFLAGS)" + globalCflags
).c_str () );
1934 cxxflagsMacro
.c_str (),
1935 (" $(PROJECT_CXXFLAGS)" + globalCflags
).c_str () );
1939 "%s += $(PROJECT_RCFLAGS)\n",
1940 windresflagsMacro
.c_str () );
1944 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
1945 widlflagsMacro
.c_str (),
1946 module
.output
->relative_path
.c_str () );
1950 "%s_LFLAGS := $(PROJECT_LFLAGS) $(%s_LFLAGS)\n",
1951 module
.name
.c_str (),
1952 module
.name
.c_str () );
1959 cflagsMacro
.c_str (),
1960 globalCflags
.c_str () );
1965 cxxflagsMacro
.c_str (),
1966 globalCflags
.c_str () );
1970 "%s_LFLAGS += $(HOST_LFLAGS)\n",
1971 module
.name
.c_str () );
1977 linkDepsMacro
.c_str (),
1978 libsMacro
.c_str () );
1980 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
1981 if ( strlen( cflags
) > 0 )
1983 fprintf ( fMakefile
,
1985 cflagsMacro
.c_str (),
1987 fprintf ( fMakefile
,
1989 cxxflagsMacro
.c_str (),
1993 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
1994 if ( strlen( nasmflags
) > 0 )
1996 fprintf ( fMakefile
,
1998 nasmflagsMacro
.c_str (),
2002 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
2003 if ( strlen( linkerflags
) > 0 )
2005 fprintf ( fMakefile
,
2007 linkerflagsMacro
.c_str (),
2011 fprintf ( fMakefile
, "\n\n" );
2013 // future references to the macros will be to get their values
2014 commonflagsMacro
= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
2015 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2016 cxxflagsMacro
= ssprintf ("$(%s)", cxxflagsMacro
.c_str ());
2017 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2018 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2022 MingwModuleHandler::GenerateRules ()
2026 fprintf ( fMakefile
, "# RULES\n" );
2027 string targetMacro
= GetTargetMacro ( module
);
2028 //CLEAN_FILE ( targetMacro );
2029 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2031 // generate phony target for module name
2032 fprintf ( fMakefile
, ".PHONY: %s\n",
2033 module
.name
.c_str () );
2034 string dependencies
= GetTargetMacro ( module
);
2035 if ( module
.type
== Test
)
2036 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2037 fprintf ( fMakefile
, "%s: %s\n\n",
2038 module
.name
.c_str (),
2039 dependencies
.c_str () );
2040 if ( module
.type
== Test
)
2042 fprintf ( fMakefile
,
2044 targetMacro
.c_str ());
2047 if ( !ReferenceObjects ( module
) )
2049 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2054 spec
= IsSpecDefinitionFile();
2061 defRule
= &winebuildPDefRule
;
2063 defRule
= &winebuildDefRule
;
2065 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
2068 GenerateObjectFileTargets ();
2072 MingwModuleHandler::GetInvocationDependencies (
2073 const Module
& module
,
2074 string_list
& dependencies
)
2076 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2078 Invoke
& invoke
= *module
.invocations
[i
];
2079 if ( invoke
.invokeModule
== &module
)
2080 /* Protect against circular dependencies */
2082 invoke
.GetTargets ( dependencies
);
2087 MingwModuleHandler::GenerateInvocations () const
2089 if ( module
.invocations
.size () == 0 )
2092 fprintf ( fMakefile
, "# INVOCATIONS\n" );
2094 size_t iend
= module
.invocations
.size ();
2095 for ( size_t i
= 0; i
< iend
; i
++ )
2097 const Invoke
& invoke
= *module
.invocations
[i
];
2099 if ( invoke
.invokeModule
->type
!= BuildTool
)
2101 throw XMLInvalidBuildFileException (
2102 module
.node
.location
,
2103 "Only modules of type buildtool can be invoked." );
2106 string invokeTarget
= module
.GetInvocationTarget ( i
);
2107 string_list invoke_targets
;
2108 assert ( invoke_targets
.size() );
2109 invoke
.GetTargets ( invoke_targets
);
2110 fprintf ( fMakefile
,
2112 invokeTarget
.c_str () );
2113 fprintf ( fMakefile
,
2115 invokeTarget
.c_str () );
2116 size_t j
, jend
= invoke_targets
.size();
2117 for ( j
= 0; j
< jend
; j
++ )
2119 fprintf ( fMakefile
,
2121 invoke_targets
[i
].c_str () );
2123 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2124 for ( j
= 1; j
< jend
; j
++ )
2125 fprintf ( fMakefile
,
2127 invoke_targets
[i
].c_str () );
2128 fprintf ( fMakefile
,
2130 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2131 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2132 fprintf ( fMakefile
,
2134 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2135 invoke
.GetParameters ().c_str () );
2140 MingwModuleHandler::GetPreconditionDependenciesName () const
2142 return module
.name
+ "_precondition";
2146 MingwModuleHandler::GetDefaultDependencies (
2147 string_list
& dependencies
) const
2149 /* Avoid circular dependency */
2150 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2153 if (module
.name
!= "psdk" &&
2154 module
.name
!= "dxsdk")
2156 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2157 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2160 if (module
.name
!= "errcodes" &&
2161 module
.name
!= "bugcodes" &&
2162 module
.name
!= "ntstatus")
2164 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2165 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2166 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2169 ///* Check if any dependent library relies on the generated headers */
2170 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2172 // const Module& m = *module.project.modules[i];
2173 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2175 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2176 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2177 // string extension = GetExtension ( sourceFile );
2178 // if (extension == ".mc" || extension == ".MC" )
2180 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2181 // dependencies.push_back ( dependency );
2188 MingwModuleHandler::GeneratePreconditionDependencies ()
2190 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
2191 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2192 string_list dependencies
;
2193 GetDefaultDependencies ( dependencies
);
2194 GetModuleDependencies ( dependencies
);
2196 GetInvocationDependencies ( module
, dependencies
);
2198 if ( dependencies
.size() )
2200 fprintf ( fMakefile
,
2202 preconditionDependenciesName
.c_str () );
2203 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2204 fprintf ( fMakefile
,
2206 dependencies
[i
].c_str () );
2207 fprintf ( fMakefile
, "\n\n" );
2210 fprintf ( fMakefile
, "\n" );
2214 MingwModuleHandler::IsSpecDefinitionFile () const
2216 if(!module
.importLibrary
)
2219 std::string ext
= GetExtension ( *module
.importLibrary
->source
);
2221 if ( ext
== ".spec" )
2224 if ( ext
== ".pspec" )
2230 /* caller needs to delete the returned object */
2232 MingwModuleHandler::GetDefinitionFilename () const
2234 if ( module
.importLibrary
== NULL
)
2237 if ( IsSpecDefinitionFile () )
2239 return new FileLocation ( IntermediateDirectory
,
2240 module
.importLibrary
->source
->relative_path
,
2241 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2245 return new FileLocation ( SourceDirectory
,
2246 module
.importLibrary
->source
->relative_path
,
2247 module
.importLibrary
->source
->name
);
2252 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2254 if ( module
.importLibrary
!= NULL
)
2256 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2257 const FileLocation
*defFilename
= GetDefinitionFilename ();
2258 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2260 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE\n" );
2262 fprintf ( fMakefile
, "%s:",
2263 backend
->GetFullName ( *library_target
).c_str () );
2267 fprintf ( fMakefile
, " %s",
2268 backend
->GetFullName ( *defFilename
).c_str () );
2271 fprintf ( fMakefile
, " | %s\n",
2272 backend
->GetFullPath ( *library_target
).c_str () );
2274 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2276 fprintf ( fMakefile
,
2277 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2278 module
.GetDllName ().c_str (),
2279 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2281 backend
->GetFullName ( *library_target
).c_str (),
2282 module
.mangledSymbols
? "" : " --kill-at",
2283 module
.underscoreSymbols
? " --add-underscore" : "" );
2287 delete library_target
;
2292 MingwModuleHandler::GetSpecObjectDependencies (
2293 vector
<FileLocation
>& dependencies
,
2294 const FileLocation
*file
) const
2296 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2297 file
->relative_path
,
2298 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2302 MingwModuleHandler::GetSpecImplibDependencies (
2303 vector
<FileLocation
>& dependencies
,
2304 const FileLocation
*file
) const
2306 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2307 file
->relative_path
,
2308 GetBasename ( file
->name
) + "_" + module
.name
+ ".auto.def" ) );
2312 MingwModuleHandler::GetMcObjectDependencies (
2313 vector
<FileLocation
>& dependencies
,
2314 const FileLocation
*file
) const
2316 string basename
= GetBasename ( file
->name
);
2318 FileLocation
defDependency ( IntermediateDirectory
,
2321 dependencies
.push_back ( defDependency
);
2323 FileLocation
stubsDependency ( IntermediateDirectory
,
2324 file
->relative_path
,
2326 dependencies
.push_back ( stubsDependency
);
2330 MingwModuleHandler::GetWidlObjectDependencies (
2331 vector
<FileLocation
>& dependencies
,
2332 const FileLocation
*file
) const
2334 string basename
= GetBasename ( file
->name
);
2335 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2337 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2338 file
->relative_path
,
2339 basename
+ "_s.c" );
2340 dependencies
.push_back ( serverSourceDependency
);
2341 dependencies
.push_back ( *generatedHeaderFilename
);
2343 delete generatedHeaderFilename
;
2347 MingwModuleHandler::GetDefinitionDependencies (
2348 vector
<FileLocation
>& dependencies
) const
2350 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2351 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2353 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2354 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2355 string extension
= GetExtension ( sourceFile
);
2357 if (extension
== ".spec" || extension
== ".pspec")
2358 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2360 if (extension
== ".idl")
2362 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2363 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2368 enum DebugSupportType
2375 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2381 case DebugKernelMode
:
2382 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2386 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2393 module
.non_if_data
.libraries
.push_back(pLibrary
);
2397 MingwAddCRTLibrary( Module
&module
)
2399 const char * crtAttr
= module
.CRT
.c_str ();
2400 const char * crtLib
= NULL
;
2402 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2404 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2406 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2407 crtLib
= "libcntpr";
2408 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2413 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2415 if ( pLibrary
->importedModule
== NULL
)
2417 throw XMLInvalidBuildFileException (
2418 module
.node
.location
,
2419 "module '%s' trying to import non-existant C runtime module '%s'",
2420 module
.name
.c_str(),
2424 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2428 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2429 : MingwModuleHandler ( module_
)
2434 MingwBuildToolModuleHandler::Process ()
2436 GenerateBuildToolModuleTarget ();
2440 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2442 string
targetMacro ( GetTargetMacro (module
) );
2443 string objectsMacro
= GetObjectsMacro ( module
);
2444 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2445 string libsMacro
= GetLibsMacro ();
2449 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2452 if ( module
.cplusplus
)
2453 linker
= "${host_gpp}";
2455 linker
= "${host_gcc}";
2457 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2458 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2459 targetMacro
.c_str (),
2460 objectsMacro
.c_str (),
2461 linkDepsMacro
.c_str (),
2462 backend
->GetFullPath ( *target_file
).c_str () );
2463 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2464 fprintf ( fMakefile
,
2465 "\t%s %s -o $@ %s %s\n\n",
2467 GetLinkerMacro ().c_str (),
2468 objectsMacro
.c_str (),
2469 libsMacro
.c_str () );
2475 MingwKernelModuleHandler::MingwKernelModuleHandler (
2476 const Module
& module_
)
2478 : MingwModuleHandler ( module_
)
2483 MingwKernelModuleHandler::Process ()
2485 GenerateKernelModuleTarget ();
2489 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2491 string
targetMacro ( GetTargetMacro ( module
) );
2492 string workingDirectory
= GetWorkingDirectory ( );
2493 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2495 GenerateImportLibraryTargetIfNeeded ();
2497 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2501 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2503 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2504 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2505 module
.baseaddress
.c_str () );
2507 GenerateLinkerCommand ( dependencies
,
2508 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2513 GeneratePhonyTarget();
2518 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2519 const Module
& module_
)
2521 : MingwModuleHandler ( module_
)
2527 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2529 MingwAddCRTLibrary ( module
);
2530 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2534 MingwKernelModeDLLModuleHandler::Process ()
2536 GenerateKernelModeDLLModuleTarget ();
2540 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2542 string
targetMacro ( GetTargetMacro ( module
) );
2543 string workingDirectory
= GetWorkingDirectory ();
2544 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2546 GenerateImportLibraryTargetIfNeeded ();
2548 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2552 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2554 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2555 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2556 module
.baseaddress
.c_str () );
2557 GenerateLinkerCommand ( dependencies
,
2563 GeneratePhonyTarget();
2568 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2569 const Module
& module_
)
2571 : MingwModuleHandler ( module_
)
2576 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2578 MingwAddCRTLibrary ( module
);
2579 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2583 MingwNativeDLLModuleHandler::Process ()
2585 GenerateNativeDLLModuleTarget ();
2589 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2591 string
targetMacro ( GetTargetMacro (module
) );
2592 string workingDirectory
= GetWorkingDirectory ( );
2593 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2595 GenerateImportLibraryTargetIfNeeded ();
2597 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2601 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2603 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2604 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2605 module
.baseaddress
.c_str () );
2606 GenerateLinkerCommand ( dependencies
,
2612 GeneratePhonyTarget();
2617 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2618 const Module
& module_
)
2620 : MingwModuleHandler ( module_
)
2625 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2627 MingwAddCRTLibrary ( module
);
2628 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2632 MingwNativeCUIModuleHandler::Process ()
2634 GenerateNativeCUIModuleTarget ();
2638 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2640 string
targetMacro ( GetTargetMacro (module
) );
2641 string workingDirectory
= GetWorkingDirectory ( );
2642 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2644 GenerateImportLibraryTargetIfNeeded ();
2646 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2650 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2652 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2653 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2654 module
.baseaddress
.c_str () );
2655 GenerateLinkerCommand ( dependencies
,
2661 GeneratePhonyTarget();
2666 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2667 const Module
& module_
)
2669 : MingwModuleHandler ( module_
)
2673 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2674 const Module
& module_
)
2676 : MingwModuleHandler ( module_
)
2681 MingwAddImplicitLibraries( Module
&module
)
2685 if ( module
.type
!= Win32DLL
2686 && module
.type
!= Win32OCX
2687 && module
.type
!= Win32CUI
2688 && module
.type
!= Win32GUI
2689 && module
.type
!= Win32SCR
)
2694 if ( module
.isDefaultEntryPoint
)
2696 if ( module
.IsDLL () )
2698 //pLibrary = new Library ( module, "__mingw_dllmain" );
2699 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2703 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2704 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2708 pLibrary
= new Library ( module
, "mingw_common" );
2709 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2711 MingwAddCRTLibrary ( module
);
2712 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2716 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2718 MingwAddImplicitLibraries ( module
);
2722 MingwWin32DLLModuleHandler::Process ()
2724 GenerateWin32DLLModuleTarget ();
2728 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2730 string
targetMacro ( GetTargetMacro (module
) );
2731 string workingDirectory
= GetWorkingDirectory ( );
2732 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2734 GenerateImportLibraryTargetIfNeeded ();
2736 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2740 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2742 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2743 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2744 module
.baseaddress
.c_str () );
2745 GenerateLinkerCommand ( dependencies
,
2751 GeneratePhonyTarget();
2757 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2759 MingwAddImplicitLibraries ( module
);
2763 MingwWin32OCXModuleHandler::Process ()
2765 GenerateWin32OCXModuleTarget ();
2769 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2771 string
targetMacro ( GetTargetMacro (module
) );
2772 string workingDirectory
= GetWorkingDirectory ( );
2773 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2775 GenerateImportLibraryTargetIfNeeded ();
2777 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2781 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2783 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2784 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2785 module
.baseaddress
.c_str () );
2786 GenerateLinkerCommand ( dependencies
,
2792 GeneratePhonyTarget();
2797 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2798 const Module
& module_
)
2800 : MingwModuleHandler ( module_
)
2805 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2807 MingwAddImplicitLibraries ( module
);
2811 MingwWin32CUIModuleHandler::Process ()
2813 GenerateWin32CUIModuleTarget ();
2817 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2819 string
targetMacro ( GetTargetMacro (module
) );
2820 string workingDirectory
= GetWorkingDirectory ( );
2821 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2823 GenerateImportLibraryTargetIfNeeded ();
2825 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2829 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2831 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2832 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2833 module
.baseaddress
.c_str () );
2834 GenerateLinkerCommand ( dependencies
,
2840 GeneratePhonyTarget();
2845 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2846 const Module
& module_
)
2848 : MingwModuleHandler ( module_
)
2853 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2855 MingwAddImplicitLibraries ( module
);
2859 MingwWin32GUIModuleHandler::Process ()
2861 GenerateWin32GUIModuleTarget ();
2865 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2867 string
targetMacro ( GetTargetMacro (module
) );
2868 string workingDirectory
= GetWorkingDirectory ( );
2869 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2871 GenerateImportLibraryTargetIfNeeded ();
2873 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2877 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2879 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2880 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2881 module
.baseaddress
.c_str () );
2882 GenerateLinkerCommand ( dependencies
,
2888 GeneratePhonyTarget();
2893 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2894 const Module
& module_
)
2896 : MingwModuleHandler ( module_
)
2901 MingwBootLoaderModuleHandler::Process ()
2903 GenerateBootLoaderModuleTarget ();
2907 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2909 string
targetName ( module
.output
->name
);
2910 string
targetMacro ( GetTargetMacro (module
) );
2911 string workingDirectory
= GetWorkingDirectory ();
2912 FileLocation
junk_tmp ( TemporaryDirectory
,
2914 module
.name
+ ".junk.tmp" );
2915 CLEAN_FILE ( junk_tmp
);
2916 string objectsMacro
= GetObjectsMacro ( module
);
2917 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2921 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2923 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2924 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2925 targetMacro
.c_str (),
2926 objectsMacro
.c_str (),
2927 linkDepsMacro
.c_str (),
2928 backend
->GetFullPath ( *target_file
).c_str () );
2930 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2932 if (Environment::GetArch() == "arm")
2934 fprintf ( fMakefile
,
2935 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
2936 backend
->GetFullName ( junk_tmp
).c_str (),
2937 objectsMacro
.c_str (),
2938 linkDepsMacro
.c_str (),
2939 GetLinkerMacro ().c_str ());
2943 fprintf ( fMakefile
,
2944 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
2945 backend
->GetFullName ( junk_tmp
).c_str (),
2946 objectsMacro
.c_str (),
2947 linkDepsMacro
.c_str (),
2948 GetLinkerMacro ().c_str ());
2950 fprintf ( fMakefile
,
2951 "\t${objcopy} -O binary %s $@\n",
2952 backend
->GetFullName ( junk_tmp
).c_str () );
2953 GenerateBuildMapCode ( &junk_tmp
);
2954 fprintf ( fMakefile
,
2955 "\t-@${rm} %s 2>$(NUL)\n",
2956 backend
->GetFullName ( junk_tmp
).c_str () );
2962 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2963 const Module
& module_
)
2964 : MingwModuleHandler ( module_
)
2969 MingwBootProgramModuleHandler::Process ()
2971 GenerateBootProgramModuleTarget ();
2975 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2977 string
targetName ( module
.output
->name
);
2978 string
targetMacro ( GetTargetMacro (module
) );
2979 string workingDirectory
= GetWorkingDirectory ();
2980 FileLocation
junk_tmp ( TemporaryDirectory
,
2982 module
.name
+ ".junk.tmp" );
2983 FileLocation
junk_elf ( TemporaryDirectory
,
2985 module
.name
+ ".junk.elf" );
2986 FileLocation
junk_cpy ( TemporaryDirectory
,
2988 module
.name
+ ".junk.elf" );
2989 CLEAN_FILE ( junk_tmp
);
2990 CLEAN_FILE ( junk_elf
);
2991 CLEAN_FILE ( junk_cpy
);
2992 string objectsMacro
= GetObjectsMacro ( module
);
2993 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2994 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
2998 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
3000 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3001 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3002 targetMacro
.c_str (),
3003 objectsMacro
.c_str (),
3004 linkDepsMacro
.c_str (),
3005 payload
->name
.c_str (),
3006 backend
->GetFullPath ( *target_file
).c_str () );
3008 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3010 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3011 module
.buildtype
.c_str (),
3012 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3013 backend
->GetFullName ( junk_cpy
).c_str () );
3015 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3016 module
.buildtype
.c_str (),
3017 backend
->GetFullName ( junk_cpy
).c_str (),
3018 backend
->GetFullName ( junk_tmp
).c_str () );
3020 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
3021 module
.buildtype
.c_str (),
3022 linkDepsMacro
.c_str (),
3023 backend
->GetFullName ( junk_tmp
).c_str (),
3024 backend
->GetFullName ( junk_elf
).c_str () );
3026 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3027 module
.buildtype
.c_str (),
3028 backend
->GetFullName ( junk_elf
).c_str (),
3029 backend
->GetFullName ( *module
.output
) .c_str () );
3031 fprintf ( fMakefile
,
3032 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3033 backend
->GetFullName ( junk_tmp
).c_str (),
3034 backend
->GetFullName ( junk_elf
).c_str (),
3035 backend
->GetFullName ( junk_cpy
).c_str () );
3041 MingwIsoModuleHandler::MingwIsoModuleHandler (
3042 const Module
& module_
)
3044 : MingwModuleHandler ( module_
)
3049 MingwIsoModuleHandler::Process ()
3051 GenerateIsoModuleTarget ();
3055 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3056 const string
& bootcdDirectory
)
3058 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3060 const Module
& m
= *p
->second
;
3063 if ( m
.bootstrap
!= NULL
)
3065 FileLocation
targetFile ( OutputDirectory
,
3066 m
.bootstrap
->base
.length () > 0
3067 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3069 m
.bootstrap
->nameoncd
);
3070 OutputCopyCommand ( *m
.output
, targetFile
);
3076 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3077 const string
& bootcdDirectory
)
3079 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3081 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3082 FileLocation
targetFile ( OutputDirectory
,
3083 cdfile
.target
->relative_path
.length () > 0
3084 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3086 cdfile
.target
->name
);
3087 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3092 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3093 const string
& bootcdDirectory
)
3095 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3097 const Module
& m
= *p
->second
;
3100 if ( m
.bootstrap
!= NULL
)
3102 FileLocation
targetDirectory ( OutputDirectory
,
3103 m
.bootstrap
->base
.length () > 0
3104 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3107 out
.push_back ( targetDirectory
);
3113 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3114 const string
& bootcdDirectory
)
3116 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3118 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3119 FileLocation
targetDirectory ( OutputDirectory
,
3120 cdfile
.target
->relative_path
.length () > 0
3121 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3124 out
.push_back( targetDirectory
);
3129 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3130 const string
& bootcdDirectory
)
3132 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3133 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3137 MingwIsoModuleHandler::GetBootstrapCdFiles (
3138 vector
<FileLocation
>& out
) const
3140 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3142 const Module
& m
= *p
->second
;
3145 if ( m
.bootstrap
!= NULL
)
3147 out
.push_back ( *m
.output
);
3153 MingwIsoModuleHandler::GetNonModuleCdFiles (
3154 vector
<FileLocation
>& out
) const
3156 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3158 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3159 out
.push_back ( *cdfile
.source
);
3164 MingwIsoModuleHandler::GetCdFiles (
3165 vector
<FileLocation
>& out
) const
3167 GetBootstrapCdFiles ( out
);
3168 GetNonModuleCdFiles ( out
);
3172 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3174 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
3175 string bootcdDirectory
= "cd";
3176 FileLocation
bootcd ( OutputDirectory
,
3179 FileLocation
bootcdReactos ( OutputDirectory
,
3180 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3182 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3183 vector
<FileLocation
> vCdDirectories
;
3186 FileLocation
srcunattend ( SourceDirectory
,
3187 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3189 FileLocation
tarunattend ( bootcdReactos
.directory
,
3190 bootcdReactos
.relative_path
,
3192 if (module
.type
== IsoRegTest
)
3193 vSourceFiles
.push_back ( srcunattend
);
3196 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3200 throw InvalidOperationException ( module
.node
.location
.c_str(),
3202 "Invalid bootsector. module '%s' requires <bootsector>",
3203 module
.name
.c_str ());
3206 const FileLocation
*isoboot
= bootModule
->output
;
3207 vSourceFiles
.push_back ( *isoboot
);
3209 // prepare reactos.dff and reactos.inf
3210 FileLocation
reactosDff ( SourceDirectory
,
3211 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3213 FileLocation
reactosInf ( bootcdReactos
.directory
,
3214 bootcdReactos
.relative_path
,
3217 vSourceFiles
.push_back ( reactosDff
);
3220 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3221 Iso/LiveIso outputs are generated in code base root
3223 string IsoName
= module
.output
->name
;
3225 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3228 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3229 GetCdFiles ( vCdFiles
);
3230 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3231 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3233 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3234 module
.name
.c_str ());
3235 fprintf ( fMakefile
,
3236 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3237 module
.name
.c_str (),
3238 backend
->GetFullName ( *isoboot
).c_str (),
3239 sourceFiles
.c_str (),
3241 cdDirectories
.c_str () );
3242 fprintf ( fMakefile
,
3243 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3244 backend
->GetFullName ( reactosDff
).c_str (),
3245 backend
->GetFullPath ( bootcdReactos
).c_str () );
3246 fprintf ( fMakefile
,
3247 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3248 backend
->GetFullName ( reactosDff
).c_str (),
3249 backend
->GetFullName ( reactosInf
).c_str (),
3250 backend
->GetFullPath ( bootcdReactos
).c_str ());
3251 fprintf ( fMakefile
,
3252 "\t-@${rm} %s 2>$(NUL)\n",
3253 backend
->GetFullName ( reactosInf
).c_str () );
3254 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3255 OutputCdfileCopyCommands ( bootcdDirectory
);
3257 if (module
.type
== IsoRegTest
)
3258 OutputCopyCommand ( srcunattend
, tarunattend
);
3260 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3261 fprintf ( fMakefile
,
3262 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3263 backend
->GetFullName ( *isoboot
).c_str (),
3264 backend
->GetFullPath ( bootcd
).c_str (),
3266 fprintf ( fMakefile
,
3271 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3272 const Module
& module_
)
3274 : MingwModuleHandler ( module_
)
3279 MingwLiveIsoModuleHandler::Process ()
3281 GenerateLiveIsoModuleTarget ();
3285 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3287 FileLocation
dir ( OutputDirectory
,
3290 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3294 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3295 string
& reactosDirectory
)
3297 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3299 const Module
& m
= *p
->second
;
3304 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3305 FileLocation
destination ( OutputDirectory
,
3306 m
.install
->relative_path
.length () > 0
3307 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3308 : livecdDirectory
+ sSep
+ reactosDirectory
,
3310 OutputCopyCommand ( *aliasedModule
.output
,
3317 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3318 string
& reactosDirectory
)
3320 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3322 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3323 FileLocation
target ( OutputDirectory
,
3324 installfile
.target
->relative_path
.length () > 0
3325 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3326 : livecdDirectory
+ sSep
+ reactosDirectory
,
3327 installfile
.target
->name
);
3328 OutputCopyCommand ( *installfile
.source
, target
);
3333 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3335 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3336 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3337 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3338 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3339 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3340 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3342 FileLocation
livecdIni ( SourceDirectory
,
3343 "boot" + sSep
+ "bootdata",
3345 FileLocation
destination ( OutputDirectory
,
3348 OutputCopyCommand ( livecdIni
,
3353 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3355 FileLocation
freeldr ( OutputDirectory
,
3356 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3358 FileLocation
destination ( OutputDirectory
,
3359 livecdDirectory
+ sSep
+ "loader",
3361 OutputCopyCommand ( freeldr
,
3366 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3368 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
3369 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3370 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3372 fprintf ( fMakefile
,
3373 "\t$(ECHO_MKHIVE)\n" );
3374 fprintf ( fMakefile
,
3375 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3376 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3377 cSep
, cSep
, cSep
, cSep
);
3381 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3383 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3384 string livecdDirectory
= module
.name
;
3385 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3390 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3394 throw InvalidOperationException ( module
.node
.location
.c_str(),
3396 "Invalid bootsector. module '%s' requires <bootsector>",
3397 module
.name
.c_str ());
3400 const FileLocation
*isoboot
= bootModule
->output
;
3403 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3404 Iso/LiveIso outputs are generated in code base root
3406 IsoName
= module
.output
->name
;
3408 string reactosDirectory
= "reactos";
3409 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3410 FileLocation
livecdReactos ( OutputDirectory
,
3411 livecdReactosNoFixup
,
3413 CLEAN_FILE ( livecdReactos
);
3415 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3416 module
.name
.c_str ());
3417 fprintf ( fMakefile
,
3418 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3419 module
.name
.c_str (),
3420 backend
->GetFullName ( *isoboot
) .c_str (),
3421 backend
->GetFullPath ( livecdReactos
).c_str () );
3422 OutputModuleCopyCommands ( livecdDirectory
,
3424 OutputNonModuleCopyCommands ( livecdDirectory
,
3426 OutputProfilesDirectoryCommands ( livecdDirectory
);
3427 OutputLoaderCommands ( livecdDirectory
);
3428 OutputRegistryCommands ( livecdDirectory
);
3429 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3430 fprintf ( fMakefile
,
3431 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3432 backend
->GetFullName( *isoboot
).c_str (),
3433 backend
->GetFullPath ( livecd
).c_str (),
3435 fprintf ( fMakefile
,
3440 MingwTestModuleHandler::MingwTestModuleHandler (
3441 const Module
& module_
)
3443 : MingwModuleHandler ( module_
)
3448 MingwTestModuleHandler::Process ()
3450 GenerateTestModuleTarget ();
3453 /* caller needs to delete the returned object */
3455 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3457 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3458 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3459 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3463 MingwTestModuleHandler::GenerateTestModuleTarget ()
3465 string
targetMacro ( GetTargetMacro ( module
) );
3466 string workingDirectory
= GetWorkingDirectory ( );
3467 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3469 GenerateImportLibraryTargetIfNeeded ();
3471 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3475 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3477 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3478 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3479 module
.baseaddress
.c_str () );
3480 GenerateLinkerCommand ( dependencies
,
3486 GeneratePhonyTarget();
3491 MingwAliasModuleHandler::MingwAliasModuleHandler (
3492 const Module
& module_
)
3494 : MingwModuleHandler ( module_
)
3499 MingwAliasModuleHandler::Process ()
3504 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3505 const Module
& module_
)
3507 : MingwModuleHandler ( module_
)
3512 MingwCabinetModuleHandler::Process ()
3514 string
targetMacro ( GetTargetMacro (module
) );
3518 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3519 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3520 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3521 targetMacro
.c_str (),
3522 backend
->GetFullPath ( *target_file
).c_str () );
3524 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3525 fprintf ( fMakefile
,
3526 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3527 targetMacro
.c_str (),
3528 module
.name
.c_str());
3531 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3532 const Module
& module_
)
3534 : MingwModuleHandler ( module_
)
3539 MingwElfExecutableModuleHandler::Process ()
3541 string
targetName ( module
.output
->name
);
3542 string
targetMacro ( GetTargetMacro (module
) );
3543 string workingDirectory
= GetWorkingDirectory ();
3544 string objectsMacro
= GetObjectsMacro ( module
);
3545 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3546 string libsMacro
= GetLibsMacro ();
3550 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3551 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3552 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3553 targetMacro
.c_str (),
3554 objectsMacro
.c_str (),
3555 linkDepsMacro
.c_str (),
3556 backend
->GetFullPath ( *target_file
).c_str () );
3558 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3560 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -gstabs+ -o %s\n",
3561 module
.buildtype
.c_str(),
3562 objectsMacro
.c_str(),
3564 targetMacro
.c_str () );