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) -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)_CFLAGS)$(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)_CFLAGS)$(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 -g %s\n\n",
1659 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1660 backend
->GetFullName ( *pchFilename
).c_str(),
1661 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::GetCFlagsMacro () const
1717 return ssprintf ( "$(%s_CFLAGS)",
1718 module
.name
.c_str () );
1722 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1724 return ssprintf ( "$(%s_OBJS)",
1725 module
.name
.c_str () );
1729 MingwModuleHandler::GetLinkingDependenciesMacro () const
1731 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1735 MingwModuleHandler::GetLibsMacro () const
1737 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1741 MingwModuleHandler::GetLinkerMacro () const
1743 return ssprintf ( "$(%s_LFLAGS)",
1744 module
.name
.c_str () );
1748 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1750 if ( ReferenceObjects ( module
) )
1751 return GetObjectsMacro ( module
);
1754 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1755 string target
= backend
->GetFullName ( *target_file
).c_str ();
1762 MingwModuleHandler::GenerateSourceMacro ()
1764 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1766 GenerateSourceMacros ( module
.non_if_data
);
1768 // future references to the macro will be to get its values
1769 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1773 MingwModuleHandler::GenerateObjectMacro ()
1775 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1777 GenerateObjectMacros ( module
.non_if_data
);
1779 // future references to the macro will be to get its values
1780 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1784 MingwModuleHandler::GenerateTargetMacro ()
1786 fprintf ( fMakefile
, "# TARGET MACRO\n" );
1787 fprintf ( fMakefile
,
1789 GetTargetMacro ( module
, false ).c_str (),
1790 GetModuleTargets ( module
).c_str () );
1794 MingwModuleHandler::GetRpcHeaderDependencies (
1795 vector
<FileLocation
>& dependencies
) const
1797 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1799 Library
& library
= *module
.non_if_data
.libraries
[i
];
1800 if ( library
.importedModule
->type
== RpcServer
||
1801 library
.importedModule
->type
== RpcClient
||
1802 library
.importedModule
->type
== RpcProxy
||
1803 library
.importedModule
->type
== IdlHeader
)
1805 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1807 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1808 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1809 string extension
= GetExtension ( sourceFile
);
1810 if ( extension
== ".idl" || extension
== ".IDL" )
1812 string basename
= GetBasename ( sourceFile
.name
);
1813 if ( library
.importedModule
->type
== RpcServer
)
1815 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1816 dependencies
.push_back ( *header
);
1819 if ( library
.importedModule
->type
== RpcClient
)
1821 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1822 dependencies
.push_back ( *header
);
1825 if ( library
.importedModule
->type
== RpcProxy
)
1827 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1828 dependencies
.push_back ( *header
);
1831 if ( library
.importedModule
->type
== IdlHeader
)
1833 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1834 dependencies
.push_back ( *header
);
1844 MingwModuleHandler::GenerateOtherMacros ()
1846 set
<const Define
*> used_defs
;
1848 fprintf ( fMakefile
, "# OTHER MACROS\n" );
1850 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1851 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1852 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1853 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1854 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1855 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1856 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1861 &module
.linkerFlags
,
1864 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1866 GenerateMacros("+=", module
.project
.host_non_if_data
, NULL
, used_defs
);
1872 module
.project
.non_if_data
,
1877 if ( IsSpecDefinitionFile() )
1879 vector
<FileLocation
> s
;
1880 GetSpecImplibDependencies ( s
, module
.importLibrary
->source
);
1885 linkDepsMacro
.c_str() );
1886 for ( size_t i
= 0; i
< s
.size(); i
++ )
1887 fprintf ( fMakefile
,
1889 backend
->GetFullName ( s
[i
] ).c_str () );
1890 fprintf ( fMakefile
, "\n" );
1893 string globalCflags
= "";
1894 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1896 globalCflags
+= " $(PROJECT_CFLAGS)";
1897 if ( module
.dynamicCRT
)
1898 globalCflags
+= " -D_DLL -D__USE_CRTIMP";
1901 globalCflags
+= " -Wall -Wpointer-arith";
1902 globalCflags
+= " -g";
1903 if ( backend
->usePipe
)
1904 globalCflags
+= " -pipe";
1905 if ( !module
.allowWarnings
)
1906 globalCflags
+= " -Werror";
1907 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1909 if ( module
.cplusplus
)
1910 globalCflags
+= " $(HOST_CPPFLAGS)";
1912 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
1916 if ( module
.cplusplus
)
1918 // HACK: use host headers when building C++
1919 globalCflags
+= " $(HOST_CPPFLAGS)";
1922 globalCflags
+= " -nostdinc";
1925 // Always force disabling of sibling calls optimisation for GCC
1926 // (TODO: Move to version-specific once this bug is fixed in GCC)
1927 globalCflags
+= " -fno-optimize-sibling-calls";
1932 cflagsMacro
.c_str (),
1933 globalCflags
.c_str () );
1935 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
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) -g $(%s_LFLAGS)\n",
1951 module
.name
.c_str (),
1952 module
.name
.c_str () );
1958 "%s_LFLAGS += $(HOST_LFLAGS)\n",
1959 module
.name
.c_str () );
1965 linkDepsMacro
.c_str (),
1966 libsMacro
.c_str () );
1968 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
1969 if ( strlen( cflags
) > 0 )
1971 fprintf ( fMakefile
,
1973 cflagsMacro
.c_str (),
1977 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
1978 if ( strlen( nasmflags
) > 0 )
1980 fprintf ( fMakefile
,
1982 nasmflagsMacro
.c_str (),
1986 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
1987 if ( strlen( linkerflags
) > 0 )
1989 fprintf ( fMakefile
,
1991 linkerflagsMacro
.c_str (),
1995 if ( IsStaticLibrary ( module
) && module
.isStartupLib
)
1997 fprintf ( fMakefile
,
1998 "%s += -Wno-main\n\n",
1999 cflagsMacro
.c_str () );
2002 fprintf ( fMakefile
, "\n\n" );
2004 // future references to the macros will be to get their values
2005 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2006 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2007 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2011 MingwModuleHandler::GenerateRules ()
2015 fprintf ( fMakefile
, "# RULES\n" );
2016 string targetMacro
= GetTargetMacro ( module
);
2017 //CLEAN_FILE ( targetMacro );
2018 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2020 // generate phony target for module name
2021 fprintf ( fMakefile
, ".PHONY: %s\n",
2022 module
.name
.c_str () );
2023 string dependencies
= GetTargetMacro ( module
);
2024 if ( module
.type
== Test
)
2025 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2026 fprintf ( fMakefile
, "%s: %s\n\n",
2027 module
.name
.c_str (),
2028 dependencies
.c_str () );
2029 if ( module
.type
== Test
)
2031 fprintf ( fMakefile
,
2033 targetMacro
.c_str ());
2036 if ( !ReferenceObjects ( module
) )
2038 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2043 spec
= IsSpecDefinitionFile();
2050 defRule
= &winebuildPDefRule
;
2052 defRule
= &winebuildDefRule
;
2054 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
2057 GenerateObjectFileTargets ();
2061 MingwModuleHandler::GetInvocationDependencies (
2062 const Module
& module
,
2063 string_list
& dependencies
)
2065 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2067 Invoke
& invoke
= *module
.invocations
[i
];
2068 if ( invoke
.invokeModule
== &module
)
2069 /* Protect against circular dependencies */
2071 invoke
.GetTargets ( dependencies
);
2076 MingwModuleHandler::GenerateInvocations () const
2078 if ( module
.invocations
.size () == 0 )
2081 fprintf ( fMakefile
, "# INVOCATIONS\n" );
2083 size_t iend
= module
.invocations
.size ();
2084 for ( size_t i
= 0; i
< iend
; i
++ )
2086 const Invoke
& invoke
= *module
.invocations
[i
];
2088 if ( invoke
.invokeModule
->type
!= BuildTool
)
2090 throw XMLInvalidBuildFileException (
2091 module
.node
.location
,
2092 "Only modules of type buildtool can be invoked." );
2095 string invokeTarget
= module
.GetInvocationTarget ( i
);
2096 string_list invoke_targets
;
2097 assert ( invoke_targets
.size() );
2098 invoke
.GetTargets ( invoke_targets
);
2099 fprintf ( fMakefile
,
2101 invokeTarget
.c_str () );
2102 fprintf ( fMakefile
,
2104 invokeTarget
.c_str () );
2105 size_t j
, jend
= invoke_targets
.size();
2106 for ( j
= 0; j
< jend
; j
++ )
2108 fprintf ( fMakefile
,
2110 invoke_targets
[i
].c_str () );
2112 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2113 for ( j
= 1; j
< jend
; j
++ )
2114 fprintf ( fMakefile
,
2116 invoke_targets
[i
].c_str () );
2117 fprintf ( fMakefile
,
2119 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2120 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2121 fprintf ( fMakefile
,
2123 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2124 invoke
.GetParameters ().c_str () );
2129 MingwModuleHandler::GetPreconditionDependenciesName () const
2131 return module
.name
+ "_precondition";
2135 MingwModuleHandler::GetDefaultDependencies (
2136 string_list
& dependencies
) const
2138 /* Avoid circular dependency */
2139 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2142 if (module
.name
!= "psdk" &&
2143 module
.name
!= "dxsdk")
2145 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2146 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2149 if (module
.name
!= "errcodes" &&
2150 module
.name
!= "bugcodes" &&
2151 module
.name
!= "ntstatus")
2153 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2154 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2155 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2158 ///* Check if any dependent library relies on the generated headers */
2159 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2161 // const Module& m = *module.project.modules[i];
2162 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2164 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2165 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2166 // string extension = GetExtension ( sourceFile );
2167 // if (extension == ".mc" || extension == ".MC" )
2169 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2170 // dependencies.push_back ( dependency );
2177 MingwModuleHandler::GeneratePreconditionDependencies ()
2179 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
2180 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2181 string_list dependencies
;
2182 GetDefaultDependencies ( dependencies
);
2183 GetModuleDependencies ( dependencies
);
2185 GetInvocationDependencies ( module
, dependencies
);
2187 if ( dependencies
.size() )
2189 fprintf ( fMakefile
,
2191 preconditionDependenciesName
.c_str () );
2192 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2193 fprintf ( fMakefile
,
2195 dependencies
[i
].c_str () );
2196 fprintf ( fMakefile
, "\n\n" );
2199 fprintf ( fMakefile
, "\n" );
2203 MingwModuleHandler::IsSpecDefinitionFile () const
2205 if(!module
.importLibrary
)
2208 std::string ext
= GetExtension ( *module
.importLibrary
->source
);
2210 if ( ext
== ".spec" )
2213 if ( ext
== ".pspec" )
2219 /* caller needs to delete the returned object */
2221 MingwModuleHandler::GetDefinitionFilename () const
2223 if ( module
.importLibrary
== NULL
)
2226 if ( IsSpecDefinitionFile () )
2228 return new FileLocation ( IntermediateDirectory
,
2229 module
.importLibrary
->source
->relative_path
,
2230 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2234 return new FileLocation ( SourceDirectory
,
2235 module
.importLibrary
->source
->relative_path
,
2236 module
.importLibrary
->source
->name
);
2241 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2243 if ( module
.importLibrary
!= NULL
)
2245 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2246 const FileLocation
*defFilename
= GetDefinitionFilename ();
2247 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2249 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE\n" );
2251 fprintf ( fMakefile
, "%s:",
2252 backend
->GetFullName ( *library_target
).c_str () );
2256 fprintf ( fMakefile
, " %s",
2257 backend
->GetFullName ( *defFilename
).c_str () );
2260 fprintf ( fMakefile
, " | %s\n",
2261 backend
->GetFullPath ( *library_target
).c_str () );
2263 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2265 fprintf ( fMakefile
,
2266 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2267 module
.GetDllName ().c_str (),
2268 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2270 backend
->GetFullName ( *library_target
).c_str (),
2271 module
.mangledSymbols
? "" : " --kill-at",
2272 module
.underscoreSymbols
? " --add-underscore" : "" );
2276 delete library_target
;
2281 MingwModuleHandler::GetSpecObjectDependencies (
2282 vector
<FileLocation
>& dependencies
,
2283 const FileLocation
*file
) const
2285 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2286 file
->relative_path
,
2287 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2291 MingwModuleHandler::GetSpecImplibDependencies (
2292 vector
<FileLocation
>& dependencies
,
2293 const FileLocation
*file
) const
2295 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2296 file
->relative_path
,
2297 GetBasename ( file
->name
) + "_" + module
.name
+ ".auto.def" ) );
2301 MingwModuleHandler::GetMcObjectDependencies (
2302 vector
<FileLocation
>& dependencies
,
2303 const FileLocation
*file
) const
2305 string basename
= GetBasename ( file
->name
);
2307 FileLocation
defDependency ( IntermediateDirectory
,
2310 dependencies
.push_back ( defDependency
);
2312 FileLocation
stubsDependency ( IntermediateDirectory
,
2313 file
->relative_path
,
2315 dependencies
.push_back ( stubsDependency
);
2319 MingwModuleHandler::GetWidlObjectDependencies (
2320 vector
<FileLocation
>& dependencies
,
2321 const FileLocation
*file
) const
2323 string basename
= GetBasename ( file
->name
);
2324 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2326 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2327 file
->relative_path
,
2328 basename
+ "_s.c" );
2329 dependencies
.push_back ( serverSourceDependency
);
2330 dependencies
.push_back ( *generatedHeaderFilename
);
2332 delete generatedHeaderFilename
;
2336 MingwModuleHandler::GetDefinitionDependencies (
2337 vector
<FileLocation
>& dependencies
) const
2339 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2340 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2342 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2343 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2344 string extension
= GetExtension ( sourceFile
);
2346 if (extension
== ".spec" || extension
== ".pspec")
2347 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2349 if (extension
== ".idl")
2351 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2352 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2357 enum DebugSupportType
2364 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2370 case DebugKernelMode
:
2371 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2375 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2382 module
.non_if_data
.libraries
.push_back(pLibrary
);
2386 MingwAddCRTLibrary( Module
&module
)
2388 const char * crtAttr
= module
.CRT
.c_str ();
2389 const char * crtLib
= NULL
;
2391 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2393 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2395 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2396 crtLib
= "libcntpr";
2397 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2402 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2404 if ( pLibrary
->importedModule
== NULL
)
2406 throw XMLInvalidBuildFileException (
2407 module
.node
.location
,
2408 "module '%s' trying to import non-existant C runtime module '%s'",
2409 module
.name
.c_str(),
2413 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2417 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2418 : MingwModuleHandler ( module_
)
2423 MingwBuildToolModuleHandler::Process ()
2425 GenerateBuildToolModuleTarget ();
2429 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2431 string
targetMacro ( GetTargetMacro (module
) );
2432 string objectsMacro
= GetObjectsMacro ( module
);
2433 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2434 string libsMacro
= GetLibsMacro ();
2438 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2441 if ( module
.cplusplus
)
2442 linker
= "${host_gpp}";
2444 linker
= "${host_gcc}";
2446 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2447 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2448 targetMacro
.c_str (),
2449 objectsMacro
.c_str (),
2450 linkDepsMacro
.c_str (),
2451 backend
->GetFullPath ( *target_file
).c_str () );
2452 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2453 fprintf ( fMakefile
,
2454 "\t%s %s -o $@ %s %s\n\n",
2456 GetLinkerMacro ().c_str (),
2457 objectsMacro
.c_str (),
2458 libsMacro
.c_str () );
2464 MingwKernelModuleHandler::MingwKernelModuleHandler (
2465 const Module
& module_
)
2467 : MingwModuleHandler ( module_
)
2472 MingwKernelModuleHandler::Process ()
2474 GenerateKernelModuleTarget ();
2478 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2480 string
targetMacro ( GetTargetMacro ( module
) );
2481 string workingDirectory
= GetWorkingDirectory ( );
2482 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2484 GenerateImportLibraryTargetIfNeeded ();
2486 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2490 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2492 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2493 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2494 module
.baseaddress
.c_str () );
2496 GenerateLinkerCommand ( dependencies
,
2497 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2502 GeneratePhonyTarget();
2507 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2508 const Module
& module_
)
2510 : MingwModuleHandler ( module_
)
2516 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2518 MingwAddCRTLibrary ( module
);
2519 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2523 MingwKernelModeDLLModuleHandler::Process ()
2525 GenerateKernelModeDLLModuleTarget ();
2529 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2531 string
targetMacro ( GetTargetMacro ( module
) );
2532 string workingDirectory
= GetWorkingDirectory ();
2533 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2535 GenerateImportLibraryTargetIfNeeded ();
2537 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2541 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2543 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2544 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2545 module
.baseaddress
.c_str () );
2546 GenerateLinkerCommand ( dependencies
,
2552 GeneratePhonyTarget();
2557 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2558 const Module
& module_
)
2560 : MingwModuleHandler ( module_
)
2565 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2567 MingwAddCRTLibrary ( module
);
2568 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2572 MingwNativeDLLModuleHandler::Process ()
2574 GenerateNativeDLLModuleTarget ();
2578 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2580 string
targetMacro ( GetTargetMacro (module
) );
2581 string workingDirectory
= GetWorkingDirectory ( );
2582 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2584 GenerateImportLibraryTargetIfNeeded ();
2586 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2590 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2592 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2593 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2594 module
.baseaddress
.c_str () );
2595 GenerateLinkerCommand ( dependencies
,
2601 GeneratePhonyTarget();
2606 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2607 const Module
& module_
)
2609 : MingwModuleHandler ( module_
)
2614 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2616 MingwAddCRTLibrary ( module
);
2617 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2621 MingwNativeCUIModuleHandler::Process ()
2623 GenerateNativeCUIModuleTarget ();
2627 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2629 string
targetMacro ( GetTargetMacro (module
) );
2630 string workingDirectory
= GetWorkingDirectory ( );
2631 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2633 GenerateImportLibraryTargetIfNeeded ();
2635 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2639 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2641 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2642 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2643 module
.baseaddress
.c_str () );
2644 GenerateLinkerCommand ( dependencies
,
2650 GeneratePhonyTarget();
2655 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2656 const Module
& module_
)
2658 : MingwModuleHandler ( module_
)
2662 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2663 const Module
& module_
)
2665 : MingwModuleHandler ( module_
)
2670 MingwAddImplicitLibraries( Module
&module
)
2674 if ( module
.type
!= Win32DLL
2675 && module
.type
!= Win32OCX
2676 && module
.type
!= Win32CUI
2677 && module
.type
!= Win32GUI
2678 && module
.type
!= Win32SCR
)
2683 if ( module
.isDefaultEntryPoint
)
2685 if ( module
.IsDLL () )
2687 //pLibrary = new Library ( module, "__mingw_dllmain" );
2688 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2692 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2693 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2697 pLibrary
= new Library ( module
, "mingw_common" );
2698 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2700 MingwAddCRTLibrary ( module
);
2701 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2705 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2707 MingwAddImplicitLibraries ( module
);
2711 MingwWin32DLLModuleHandler::Process ()
2713 GenerateWin32DLLModuleTarget ();
2717 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2719 string
targetMacro ( GetTargetMacro (module
) );
2720 string workingDirectory
= GetWorkingDirectory ( );
2721 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2723 GenerateImportLibraryTargetIfNeeded ();
2725 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2729 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2731 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2732 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2733 module
.baseaddress
.c_str () );
2734 GenerateLinkerCommand ( dependencies
,
2740 GeneratePhonyTarget();
2746 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2748 MingwAddImplicitLibraries ( module
);
2752 MingwWin32OCXModuleHandler::Process ()
2754 GenerateWin32OCXModuleTarget ();
2758 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2760 string
targetMacro ( GetTargetMacro (module
) );
2761 string workingDirectory
= GetWorkingDirectory ( );
2762 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2764 GenerateImportLibraryTargetIfNeeded ();
2766 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2770 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2772 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2773 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2774 module
.baseaddress
.c_str () );
2775 GenerateLinkerCommand ( dependencies
,
2781 GeneratePhonyTarget();
2786 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2787 const Module
& module_
)
2789 : MingwModuleHandler ( module_
)
2794 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2796 MingwAddImplicitLibraries ( module
);
2800 MingwWin32CUIModuleHandler::Process ()
2802 GenerateWin32CUIModuleTarget ();
2806 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2808 string
targetMacro ( GetTargetMacro (module
) );
2809 string workingDirectory
= GetWorkingDirectory ( );
2810 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2812 GenerateImportLibraryTargetIfNeeded ();
2814 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2818 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2820 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2821 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2822 module
.baseaddress
.c_str () );
2823 GenerateLinkerCommand ( dependencies
,
2829 GeneratePhonyTarget();
2834 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2835 const Module
& module_
)
2837 : MingwModuleHandler ( module_
)
2842 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2844 MingwAddImplicitLibraries ( module
);
2848 MingwWin32GUIModuleHandler::Process ()
2850 GenerateWin32GUIModuleTarget ();
2854 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2856 string
targetMacro ( GetTargetMacro (module
) );
2857 string workingDirectory
= GetWorkingDirectory ( );
2858 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2860 GenerateImportLibraryTargetIfNeeded ();
2862 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2866 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2868 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2869 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2870 module
.baseaddress
.c_str () );
2871 GenerateLinkerCommand ( dependencies
,
2877 GeneratePhonyTarget();
2882 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2883 const Module
& module_
)
2885 : MingwModuleHandler ( module_
)
2890 MingwBootLoaderModuleHandler::Process ()
2892 GenerateBootLoaderModuleTarget ();
2896 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2898 string
targetName ( module
.output
->name
);
2899 string
targetMacro ( GetTargetMacro (module
) );
2900 string workingDirectory
= GetWorkingDirectory ();
2901 FileLocation
junk_tmp ( TemporaryDirectory
,
2903 module
.name
+ ".junk.tmp" );
2904 CLEAN_FILE ( junk_tmp
);
2905 string objectsMacro
= GetObjectsMacro ( module
);
2906 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2910 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2912 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2913 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2914 targetMacro
.c_str (),
2915 objectsMacro
.c_str (),
2916 linkDepsMacro
.c_str (),
2917 backend
->GetFullPath ( *target_file
).c_str () );
2919 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2921 if (Environment::GetArch() == "arm")
2923 fprintf ( fMakefile
,
2924 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
2925 backend
->GetFullName ( junk_tmp
).c_str (),
2926 objectsMacro
.c_str (),
2927 linkDepsMacro
.c_str (),
2928 GetLinkerMacro ().c_str ());
2932 fprintf ( fMakefile
,
2933 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
2934 backend
->GetFullName ( junk_tmp
).c_str (),
2935 objectsMacro
.c_str (),
2936 linkDepsMacro
.c_str (),
2937 GetLinkerMacro ().c_str ());
2939 fprintf ( fMakefile
,
2940 "\t${objcopy} -O binary %s $@\n",
2941 backend
->GetFullName ( junk_tmp
).c_str () );
2942 GenerateBuildMapCode ( &junk_tmp
);
2943 fprintf ( fMakefile
,
2944 "\t-@${rm} %s 2>$(NUL)\n",
2945 backend
->GetFullName ( junk_tmp
).c_str () );
2951 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2952 const Module
& module_
)
2953 : MingwModuleHandler ( module_
)
2958 MingwBootProgramModuleHandler::Process ()
2960 GenerateBootProgramModuleTarget ();
2964 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2966 string
targetName ( module
.output
->name
);
2967 string
targetMacro ( GetTargetMacro (module
) );
2968 string workingDirectory
= GetWorkingDirectory ();
2969 FileLocation
junk_tmp ( TemporaryDirectory
,
2971 module
.name
+ ".junk.tmp" );
2972 FileLocation
junk_elf ( TemporaryDirectory
,
2974 module
.name
+ ".junk.elf" );
2975 FileLocation
junk_cpy ( TemporaryDirectory
,
2977 module
.name
+ ".junk.elf" );
2978 CLEAN_FILE ( junk_tmp
);
2979 CLEAN_FILE ( junk_elf
);
2980 CLEAN_FILE ( junk_cpy
);
2981 string objectsMacro
= GetObjectsMacro ( module
);
2982 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2983 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
2987 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
2989 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2990 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
2991 targetMacro
.c_str (),
2992 objectsMacro
.c_str (),
2993 linkDepsMacro
.c_str (),
2994 payload
->name
.c_str (),
2995 backend
->GetFullPath ( *target_file
).c_str () );
2997 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
2999 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3000 module
.buildtype
.c_str (),
3001 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3002 backend
->GetFullName ( junk_cpy
).c_str () );
3004 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3005 module
.buildtype
.c_str (),
3006 backend
->GetFullName ( junk_cpy
).c_str (),
3007 backend
->GetFullName ( junk_tmp
).c_str () );
3009 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3010 module
.buildtype
.c_str (),
3011 linkDepsMacro
.c_str (),
3012 backend
->GetFullName ( junk_tmp
).c_str (),
3013 backend
->GetFullName ( junk_elf
).c_str () );
3015 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3016 module
.buildtype
.c_str (),
3017 backend
->GetFullName ( junk_elf
).c_str (),
3018 backend
->GetFullName ( *module
.output
) .c_str () );
3020 fprintf ( fMakefile
,
3021 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3022 backend
->GetFullName ( junk_tmp
).c_str (),
3023 backend
->GetFullName ( junk_elf
).c_str (),
3024 backend
->GetFullName ( junk_cpy
).c_str () );
3030 MingwIsoModuleHandler::MingwIsoModuleHandler (
3031 const Module
& module_
)
3033 : MingwModuleHandler ( module_
)
3038 MingwIsoModuleHandler::Process ()
3040 GenerateIsoModuleTarget ();
3044 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3045 const string
& bootcdDirectory
)
3047 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3049 const Module
& m
= *p
->second
;
3052 if ( m
.bootstrap
!= NULL
)
3054 FileLocation
targetFile ( OutputDirectory
,
3055 m
.bootstrap
->base
.length () > 0
3056 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3058 m
.bootstrap
->nameoncd
);
3059 OutputCopyCommand ( *m
.output
, targetFile
);
3065 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3066 const string
& bootcdDirectory
)
3068 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3070 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3071 FileLocation
targetFile ( OutputDirectory
,
3072 cdfile
.target
->relative_path
.length () > 0
3073 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3075 cdfile
.target
->name
);
3076 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3081 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3082 const string
& bootcdDirectory
)
3084 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3086 const Module
& m
= *p
->second
;
3089 if ( m
.bootstrap
!= NULL
)
3091 FileLocation
targetDirectory ( OutputDirectory
,
3092 m
.bootstrap
->base
.length () > 0
3093 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3096 out
.push_back ( targetDirectory
);
3102 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3103 const string
& bootcdDirectory
)
3105 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3107 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3108 FileLocation
targetDirectory ( OutputDirectory
,
3109 cdfile
.target
->relative_path
.length () > 0
3110 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3113 out
.push_back( targetDirectory
);
3118 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3119 const string
& bootcdDirectory
)
3121 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3122 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3126 MingwIsoModuleHandler::GetBootstrapCdFiles (
3127 vector
<FileLocation
>& out
) const
3129 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3131 const Module
& m
= *p
->second
;
3134 if ( m
.bootstrap
!= NULL
)
3136 out
.push_back ( *m
.output
);
3142 MingwIsoModuleHandler::GetNonModuleCdFiles (
3143 vector
<FileLocation
>& out
) const
3145 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3147 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3148 out
.push_back ( *cdfile
.source
);
3153 MingwIsoModuleHandler::GetCdFiles (
3154 vector
<FileLocation
>& out
) const
3156 GetBootstrapCdFiles ( out
);
3157 GetNonModuleCdFiles ( out
);
3161 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3163 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
3164 string bootcdDirectory
= "cd";
3165 FileLocation
bootcd ( OutputDirectory
,
3168 FileLocation
bootcdReactos ( OutputDirectory
,
3169 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3171 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3172 vector
<FileLocation
> vCdDirectories
;
3175 FileLocation
srcunattend ( SourceDirectory
,
3176 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3178 FileLocation
tarunattend ( bootcdReactos
.directory
,
3179 bootcdReactos
.relative_path
,
3181 if (module
.type
== IsoRegTest
)
3182 vSourceFiles
.push_back ( srcunattend
);
3185 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3189 throw InvalidOperationException ( module
.node
.location
.c_str(),
3191 "Invalid bootsector. module '%s' requires <bootsector>",
3192 module
.name
.c_str ());
3195 const FileLocation
*isoboot
= bootModule
->output
;
3196 vSourceFiles
.push_back ( *isoboot
);
3198 // prepare reactos.dff and reactos.inf
3199 FileLocation
reactosDff ( SourceDirectory
,
3200 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3202 FileLocation
reactosInf ( bootcdReactos
.directory
,
3203 bootcdReactos
.relative_path
,
3206 vSourceFiles
.push_back ( reactosDff
);
3209 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3210 Iso/LiveIso outputs are generated in code base root
3212 string IsoName
= module
.output
->name
;
3214 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3217 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3218 GetCdFiles ( vCdFiles
);
3219 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3220 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3222 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3223 module
.name
.c_str ());
3224 fprintf ( fMakefile
,
3225 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3226 module
.name
.c_str (),
3227 backend
->GetFullName ( *isoboot
).c_str (),
3228 sourceFiles
.c_str (),
3230 cdDirectories
.c_str () );
3231 fprintf ( fMakefile
,
3232 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3233 backend
->GetFullName ( reactosDff
).c_str (),
3234 backend
->GetFullPath ( bootcdReactos
).c_str () );
3235 fprintf ( fMakefile
,
3236 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3237 backend
->GetFullName ( reactosDff
).c_str (),
3238 backend
->GetFullName ( reactosInf
).c_str (),
3239 backend
->GetFullPath ( bootcdReactos
).c_str ());
3240 fprintf ( fMakefile
,
3241 "\t-@${rm} %s 2>$(NUL)\n",
3242 backend
->GetFullName ( reactosInf
).c_str () );
3243 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3244 OutputCdfileCopyCommands ( bootcdDirectory
);
3246 if (module
.type
== IsoRegTest
)
3247 OutputCopyCommand ( srcunattend
, tarunattend
);
3249 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3250 fprintf ( fMakefile
,
3251 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3252 backend
->GetFullName ( *isoboot
).c_str (),
3253 backend
->GetFullPath ( bootcd
).c_str (),
3255 fprintf ( fMakefile
,
3260 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3261 const Module
& module_
)
3263 : MingwModuleHandler ( module_
)
3268 MingwLiveIsoModuleHandler::Process ()
3270 GenerateLiveIsoModuleTarget ();
3274 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3276 FileLocation
dir ( OutputDirectory
,
3279 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3283 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3284 string
& reactosDirectory
)
3286 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3288 const Module
& m
= *p
->second
;
3293 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3294 FileLocation
destination ( OutputDirectory
,
3295 m
.install
->relative_path
.length () > 0
3296 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3297 : livecdDirectory
+ sSep
+ reactosDirectory
,
3299 OutputCopyCommand ( *aliasedModule
.output
,
3306 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3307 string
& reactosDirectory
)
3309 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3311 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3312 FileLocation
target ( OutputDirectory
,
3313 installfile
.target
->relative_path
.length () > 0
3314 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3315 : livecdDirectory
+ sSep
+ reactosDirectory
,
3316 installfile
.target
->name
);
3317 OutputCopyCommand ( *installfile
.source
, target
);
3322 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3324 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3325 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3326 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3327 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3328 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3329 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3331 FileLocation
livecdIni ( SourceDirectory
,
3332 "boot" + sSep
+ "bootdata",
3334 FileLocation
destination ( OutputDirectory
,
3337 OutputCopyCommand ( livecdIni
,
3342 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3344 FileLocation
freeldr ( OutputDirectory
,
3345 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3347 FileLocation
destination ( OutputDirectory
,
3348 livecdDirectory
+ sSep
+ "loader",
3350 OutputCopyCommand ( freeldr
,
3355 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3357 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
3358 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3359 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3361 fprintf ( fMakefile
,
3362 "\t$(ECHO_MKHIVE)\n" );
3363 fprintf ( fMakefile
,
3364 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3365 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3366 cSep
, cSep
, cSep
, cSep
);
3370 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3372 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3373 string livecdDirectory
= module
.name
;
3374 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3379 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3383 throw InvalidOperationException ( module
.node
.location
.c_str(),
3385 "Invalid bootsector. module '%s' requires <bootsector>",
3386 module
.name
.c_str ());
3389 const FileLocation
*isoboot
= bootModule
->output
;
3392 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3393 Iso/LiveIso outputs are generated in code base root
3395 IsoName
= module
.output
->name
;
3397 string reactosDirectory
= "reactos";
3398 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3399 FileLocation
livecdReactos ( OutputDirectory
,
3400 livecdReactosNoFixup
,
3402 CLEAN_FILE ( livecdReactos
);
3404 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3405 module
.name
.c_str ());
3406 fprintf ( fMakefile
,
3407 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3408 module
.name
.c_str (),
3409 backend
->GetFullName ( *isoboot
) .c_str (),
3410 backend
->GetFullPath ( livecdReactos
).c_str () );
3411 OutputModuleCopyCommands ( livecdDirectory
,
3413 OutputNonModuleCopyCommands ( livecdDirectory
,
3415 OutputProfilesDirectoryCommands ( livecdDirectory
);
3416 OutputLoaderCommands ( livecdDirectory
);
3417 OutputRegistryCommands ( livecdDirectory
);
3418 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3419 fprintf ( fMakefile
,
3420 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3421 backend
->GetFullName( *isoboot
).c_str (),
3422 backend
->GetFullPath ( livecd
).c_str (),
3424 fprintf ( fMakefile
,
3429 MingwTestModuleHandler::MingwTestModuleHandler (
3430 const Module
& module_
)
3432 : MingwModuleHandler ( module_
)
3437 MingwTestModuleHandler::Process ()
3439 GenerateTestModuleTarget ();
3442 /* caller needs to delete the returned object */
3444 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3446 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3447 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3448 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3452 MingwTestModuleHandler::GenerateTestModuleTarget ()
3454 string
targetMacro ( GetTargetMacro ( module
) );
3455 string workingDirectory
= GetWorkingDirectory ( );
3456 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3458 GenerateImportLibraryTargetIfNeeded ();
3460 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3464 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3466 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3467 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3468 module
.baseaddress
.c_str () );
3469 GenerateLinkerCommand ( dependencies
,
3475 GeneratePhonyTarget();
3480 MingwAliasModuleHandler::MingwAliasModuleHandler (
3481 const Module
& module_
)
3483 : MingwModuleHandler ( module_
)
3488 MingwAliasModuleHandler::Process ()
3493 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3494 const Module
& module_
)
3496 : MingwModuleHandler ( module_
)
3501 MingwCabinetModuleHandler::Process ()
3503 string
targetMacro ( GetTargetMacro (module
) );
3507 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3508 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3509 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3510 targetMacro
.c_str (),
3511 backend
->GetFullPath ( *target_file
).c_str () );
3513 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3514 fprintf ( fMakefile
,
3515 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3516 targetMacro
.c_str (),
3517 module
.name
.c_str());
3520 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3521 const Module
& module_
)
3523 : MingwModuleHandler ( module_
)
3528 MingwElfExecutableModuleHandler::Process ()
3530 string
targetName ( module
.output
->name
);
3531 string
targetMacro ( GetTargetMacro (module
) );
3532 string workingDirectory
= GetWorkingDirectory ();
3533 string objectsMacro
= GetObjectsMacro ( module
);
3534 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3535 string libsMacro
= GetLibsMacro ();
3539 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3540 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3541 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3542 targetMacro
.c_str (),
3543 objectsMacro
.c_str (),
3544 linkDepsMacro
.c_str (),
3545 backend
->GetFullPath ( *target_file
).c_str () );
3547 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3549 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3550 module
.buildtype
.c_str(),
3551 objectsMacro
.c_str(),
3553 targetMacro
.c_str () );