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 #define DEBUG_FORMAT " -gdwarf-2"
38 #define DEBUG_FORMAT " -gstabs+"
42 MingwModuleHandler::backend
= NULL
;
44 MingwModuleHandler::fMakefile
= NULL
;
48 const string
& filename
,
49 const string
& prefix
)
51 if ( !prefix
.length() )
54 const char* pfilename
= filename
.c_str();
55 const char* p1
= strrchr ( pfilename
, '/' );
56 const char* p2
= strrchr ( pfilename
, '\\' );
61 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
64 out
+= prefix
+ pfilename
;
69 GetTargetMacro ( const Module
& module
, bool with_dollar
)
71 string
s ( module
.name
);
75 return ssprintf ( "$(%s)", s
.c_str() );
79 MingwModuleHandler::MingwModuleHandler (
80 const Module
& module_
)
87 MingwModuleHandler::~MingwModuleHandler()
92 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
98 MingwModuleHandler::SetMakefile ( FILE* f
)
104 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
109 /*static*/ const FileLocation
*
110 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
112 switch ( file
->directory
)
114 case SourceDirectory
:
116 case IntermediateDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
119 case OutputDirectory
:
120 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
122 case InstallDirectory
:
123 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
126 throw InvalidOperationException ( __FILE__
,
128 "Invalid directory %d.",
135 /* caller needs to delete the returned object */
137 MingwModuleHandler::GetTargetFilename (
138 const Module
& module
,
139 string_list
* pclean_files
)
141 FileLocation
*target
= new FileLocation ( *module
.output
);
144 string_list
& clean_files
= *pclean_files
;
145 CLEAN_FILE ( *target
);
150 /* caller needs to delete the returned object */
152 MingwModuleHandler::GetImportLibraryFilename (
153 const Module
& module
,
154 string_list
* pclean_files
)
156 FileLocation
*target
= new FileLocation ( *module
.dependency
);
159 string_list
& clean_files
= *pclean_files
;
160 CLEAN_FILE ( *target
);
165 /* caller needs to delete the returned object */
167 MingwModuleHandler::InstanciateHandler (
168 const Module
& module
,
169 MingwBackend
* backend
)
171 MingwModuleHandler
* handler
;
172 switch ( module
.type
)
175 case HostStaticLibrary
:
182 case EmbeddedTypeLib
:
184 handler
= new MingwModuleHandler( module
);
187 handler
= new MingwBuildToolModuleHandler ( module
);
190 handler
= new MingwKernelModuleHandler ( module
);
193 handler
= new MingwNativeCUIModuleHandler ( module
);
196 handler
= new MingwWin32CUIModuleHandler ( module
);
200 handler
= new MingwWin32GUIModuleHandler ( module
);
204 case KernelModeDriver
:
205 handler
= new MingwKernelModeDLLModuleHandler ( module
);
208 handler
= new MingwNativeDLLModuleHandler ( module
);
211 handler
= new MingwWin32DLLModuleHandler ( module
);
214 handler
= new MingwWin32OCXModuleHandler ( module
);
217 handler
= new MingwBootLoaderModuleHandler ( module
);
220 handler
= new MingwBootProgramModuleHandler ( module
);
223 handler
= new MingwIsoModuleHandler ( module
);
226 handler
= new MingwLiveIsoModuleHandler ( module
);
229 handler
= new MingwIsoModuleHandler ( module
);
232 handler
= new MingwLiveIsoModuleHandler ( module
);
235 handler
= new MingwTestModuleHandler ( module
);
238 handler
= new MingwAliasModuleHandler ( module
);
241 handler
= new MingwCabinetModuleHandler ( module
);
244 handler
= new MingwElfExecutableModuleHandler ( module
);
247 throw UnknownModuleTypeException (
248 module
.node
.location
,
256 MingwModuleHandler::GetWorkingDirectory () const
262 MingwModuleHandler::GetBasename ( const string
& filename
) const
264 size_t index
= filename
.find_last_of ( '.' );
265 if ( index
!= string::npos
)
266 return filename
.substr ( 0, index
);
271 MingwModuleHandler::GetCompilationUnitDependencies (
272 const CompilationUnit
& compilationUnit
) const
274 if ( compilationUnit
.GetFiles ().size () <= 1 )
276 vector
<string
> sourceFiles
;
277 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
279 const File
& file
= *compilationUnit
.GetFiles ()[i
];
280 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
282 return string ( " " ) + v2s ( sourceFiles
, 10 );
285 /* caller needs to delete the returned object */
287 MingwModuleHandler::GetModuleArchiveFilename () const
289 if ( IsStaticLibrary ( module
) )
290 return GetTargetFilename ( module
, NULL
);
291 return new FileLocation ( IntermediateDirectory
,
292 module
.output
->relative_path
,
293 ReplaceExtension ( module
.name
, ".temp.a" ) );
297 MingwModuleHandler::ReferenceObjects (
298 const Module
& module
)
300 if ( module
.type
== ObjectLibrary
)
302 if ( module
.type
== RpcServer
)
304 if ( module
.type
== RpcClient
)
306 if ( module
.type
== RpcProxy
)
308 if ( module
.type
== IdlHeader
)
310 if ( module
.type
== MessageHeader
)
316 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
317 const FileLocation
& destination
)
319 fprintf ( fMakefile
, "# OUTPUT COPY COMMAND\n" );
323 "\t${cp} %s %s 1>$(NUL)\n",
324 backend
->GetFullName ( source
).c_str (),
325 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
329 MingwModuleHandler::GetImportLibraryDependency (
330 const Module
& importedModule
)
333 if ( ReferenceObjects ( importedModule
) )
335 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
338 dep
= GetTargetMacro ( importedModule
);
339 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
341 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
342 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
343 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
344 if ( GetExtension ( *objectFilename
) == ".h" )
345 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
346 else if ( GetExtension ( *objectFilename
) == ".rc" )
347 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
352 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
353 dep
= backend
->GetFullName ( *library_target
);
354 delete library_target
;
357 if ( IsStaticLibrary ( importedModule
) || importedModule
.type
== ObjectLibrary
)
359 const std::vector
<Library
*>& libraries
= importedModule
.non_if_data
.libraries
;
361 for ( size_t i
= 0; i
< libraries
.size (); ++ i
)
364 dep
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
372 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
373 string_list
& targets
)
375 if ( dependencyModule
.invocations
.size () > 0 )
377 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
379 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
380 invoke
.GetTargets ( targets
);
384 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
388 MingwModuleHandler::GetModuleDependencies (
389 string_list
& dependencies
)
391 size_t iend
= module
.dependencies
.size ();
396 for ( size_t i
= 0; i
< iend
; i
++ )
398 const Dependency
& dependency
= *module
.dependencies
[i
];
399 const Module
& dependencyModule
= *dependency
.dependencyModule
;
400 GetTargets ( dependencyModule
,
403 vector
<FileLocation
> v
;
404 GetDefinitionDependencies ( v
);
406 for ( size_t i
= 0; i
< v
.size (); i
++ )
408 const FileLocation
& file
= v
[i
];
409 dependencies
.push_back ( backend
->GetFullName ( file
) );
413 /* caller needs to delete the returned object */
415 MingwModuleHandler::GetObjectFilename (
416 const FileLocation
* sourceFile
,
417 const Module
& module
) const
419 DirectoryLocation destination_directory
;
421 string extension
= GetExtension ( *sourceFile
);
423 if ( module
.type
== BootSector
)
424 return new FileLocation ( *module
.output
);
425 else if (extension
== ".rc")
426 newExtension
= "_" + module
.name
+ ".coff";
427 else if (extension
== ".mc")
428 newExtension
= ".rc";
429 else if (extension
== ".idl")
431 if ( module
.type
== RpcServer
)
432 newExtension
= "_s.o";
433 else if ( module
.type
== RpcClient
)
434 newExtension
= "_c.o";
435 else if ( module
.type
== RpcProxy
)
436 newExtension
= "_p.o";
441 newExtension
= "_" + module
.name
+ ".o";
443 if ( module
.type
== BootSector
)
444 destination_directory
= OutputDirectory
;
446 destination_directory
= IntermediateDirectory
;
448 const FileLocation
*obj_file
= new FileLocation(
449 destination_directory
,
450 sourceFile
->relative_path
,
451 ReplaceExtension ( sourceFile
->name
, newExtension
) );
452 PassThruCacheDirectory ( obj_file
);
458 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
460 return module
.name
+ "_clean";
464 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
466 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
468 Library
& library
= *module
.non_if_data
.libraries
[i
];
469 if ( library
.importedModule
->type
== ObjectLibrary
)
470 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
475 MingwModuleHandler::GenerateCleanTarget () const
477 if ( module
.type
== Alias
)
480 fprintf ( fMakefile
, "# CLEAN TARGET\n" );
482 ".PHONY: %s_clean\n",
483 module
.name
.c_str() );
484 vector
<string
> referencedModuleNames
;
485 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
488 GetModuleCleanTarget ( module
).c_str(),
489 v2s ( referencedModuleNames
, 10 ).c_str () );
490 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
492 if ( ( i
+ 1 ) % 10 == 9 )
493 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
494 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
496 fprintf ( fMakefile
, " 2>$(NUL)\n" );
498 if( ProxyMakefile::GenerateProxyMakefile(module
) )
500 DirectoryLocation root
;
502 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
503 root
= SourceDirectory
;
505 root
= OutputDirectory
;
507 FileLocation
proxyMakefile ( root
,
508 module
.output
->relative_path
,
510 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
511 backend
->GetFullName ( proxyMakefile
).c_str () );
514 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
518 MingwModuleHandler::GenerateInstallTarget () const
520 if ( !module
.install
)
522 fprintf ( fMakefile
, "# INSTALL TARGET\n" );
523 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
526 module
.name
.c_str (),
527 backend
->GetFullName ( *module
.install
).c_str () );
531 MingwModuleHandler::GenerateDependsTarget () const
533 fprintf ( fMakefile
, "# DEPENDS TARGET\n" );
535 ".PHONY: %s_depends\n",
536 module
.name
.c_str() );
538 "%s_depends: $(RBUILD_TARGET)\n",
539 module
.name
.c_str () );
541 "\t$(ECHO_RBUILD)\n" );
543 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
544 module
.name
.c_str () );
548 MingwModuleHandler::GenerateGccDefineParametersFromVector (
549 const vector
<Define
*>& defines
,
550 set
<string
>& used_defs
)
554 for ( size_t i
= 0; i
< defines
.size (); i
++ )
556 Define
& define
= *defines
[i
];
557 if (used_defs
.find(define
.name
) != used_defs
.end())
559 if (parameters
.length () > 0)
561 if (define
.name
.find('(') != string::npos
)
562 parameters
+= "$(QT)";
564 parameters
+= define
.name
;
565 if (define
.value
.length () > 0)
568 parameters
+= define
.value
;
570 if (define
.name
.find('(') != string::npos
)
571 parameters
+= "$(QT)";
572 used_defs
.insert(used_defs
.begin(),define
.name
);
578 MingwModuleHandler::ConcatenatePaths (
580 const string
& path2
) const
582 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
584 if ( path1
[path1
.length ()] == cSep
)
585 return path1
+ path2
;
587 return path1
+ cSep
+ path2
;
591 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
593 string parameters
, path_prefix
;
594 for ( size_t i
= 0; i
< includes
.size (); i
++ )
596 Include
& include
= *includes
[i
];
597 if ( parameters
.length () > 0 )
599 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
605 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
608 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
610 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
611 if ( compilerFlag
.compiler
== type
)
612 parameters
+= " " + compilerFlag
.flag
;
618 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
621 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
623 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
624 if ( parameters
.length () > 0 )
626 parameters
+= linkerFlag
.flag
;
632 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
633 const vector
<Library
*>& libraries
)
635 string
dependencies ( "" );
637 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
639 if ( wrap_count
++ == 5 )
640 dependencies
+= " \\\n\t\t", wrap_count
= 0;
641 else if ( dependencies
.size () > 0 )
643 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
649 MingwModuleHandler::GenerateLinkerParameters () const
651 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
655 MingwModuleHandler::GenerateMacro (
656 const char* assignmentOperation
,
658 const IfableData
& data
,
659 set
<const Define
*> *used_defs
,
660 bool generatingCompilerMacro
)
663 bool generateAssignment
;
665 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
666 if ( generatingCompilerMacro
)
667 generateAssignment
|= data
.compilerFlags
.size () > 0;
668 if ( generateAssignment
)
673 assignmentOperation
);
676 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
681 backend
->GetFullPath ( *pchFilename
).c_str () );
685 if ( generatingCompilerMacro
)
687 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
688 if ( compilerParameters
.size () > 0 )
693 compilerParameters
.c_str () );
696 for ( i
= 0; i
< data
.includes
.size(); i
++ )
698 const Include
& include
= *data
.includes
[i
];
699 const FileLocation
* includeDirectory
= include
.directory
;
703 backend
->GetFullPath ( *includeDirectory
).c_str() );
705 for ( i
= 0; i
< data
.defines
.size(); i
++ )
707 const Define
& define
= *data
.defines
[i
];
710 set
<const Define
*>::const_iterator last_define
;
711 for (last_define
= used_defs
->begin ();
712 last_define
!= used_defs
->end ();
715 if ( (*last_define
)->name
!= define
.name
)
717 if ( !define
.overridable
)
719 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
721 "Invalid override of define '%s', already defined at %s",
722 define
.name
.c_str (),
723 define
.node
->location
.c_str () );
725 if ( backend
->configuration
.Verbose
)
726 printf("%s: Overriding '%s' already defined at %s\n",
727 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
728 define
.node
->location
.c_str () );
731 if ( last_define
!= used_defs
->end () )
737 define
.name
.c_str() );
738 if (define
.value
.length () > 0)
742 define
.value
.c_str() );
744 used_defs
->insert( used_defs
->begin (), &define
);
746 if ( generateAssignment
)
748 fprintf ( fMakefile
, "\n" );
753 MingwModuleHandler::GenerateMacros (
754 const char* assignmentOperation
,
755 const IfableData
& data
,
756 const vector
<LinkerFlag
*>* linkerFlags
,
757 set
<const Define
*>& used_defs
)
759 fprintf ( fMakefile
, "# MACROS\n" );
760 GenerateMacro ( assignmentOperation
,
765 GenerateMacro ( assignmentOperation
,
771 if ( linkerFlags
!= NULL
)
773 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
774 if ( linkerParameters
.size () > 0 )
779 linkerflagsMacro
.c_str (),
781 linkerParameters
.c_str() );
785 if ( data
.libraries
.size () > 0 )
787 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
788 if ( deps
.size () > 0 )
801 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
803 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
804 delete compilationUnits
[i
];
808 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
813 MingwModuleHandler::GenerateSourceMacros (
814 const IfableData
& data
)
818 fprintf ( fMakefile
, "# SOURCE MACROS\n" );
819 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
820 vector
<const FileLocation
*> headers
;
821 if ( compilationUnits
.size () > 0 )
826 sourcesMacro
.c_str () );
827 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
829 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
830 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
834 ( i
%10 == 9 ? " \\\n\t" : " " ),
835 backend
->GetFullName ( compilationName
).c_str () );
837 fprintf ( fMakefile
, "\n" );
840 vector
<CompilationUnit
*> sourceCompilationUnits
;
841 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
842 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
844 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
848 sourcesMacro
.c_str(),
849 backend
->GetFullName ( compilationName
).c_str () );
851 CleanupCompilationUnitVector ( sourceCompilationUnits
);
855 MingwModuleHandler::GenerateObjectMacros (
856 const IfableData
& data
)
859 const char* assignmentOperation
= "=";
861 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
862 vector
<const FileLocation
*> headers
;
863 vector
<const FileLocation
*> mcheaders
;
864 vector
<const FileLocation
*> mcresources
;
865 fprintf ( fMakefile
, "# OBJECT MACROS\n" );
866 if ( compilationUnits
.size () > 0 )
868 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
870 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
871 if ( compilationUnit
.IsFirstFile () )
873 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
874 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
877 objectsMacro
.c_str(),
878 backend
->GetFullName ( *object_file
).c_str () );
880 assignmentOperation
= "+=";
887 objectsMacro
.c_str (),
888 assignmentOperation
);
889 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
891 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
892 if ( !compilationUnit
.IsFirstFile () )
894 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
895 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
896 if ( GetExtension ( *objectFilename
) == ".h" )
897 headers
.push_back ( objectFilename
);
898 else if ( GetExtension ( *objectFilename
) == ".rc" )
900 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
901 mcheaders
.push_back ( headerFilename
);
902 mcresources
.push_back ( objectFilename
);
909 ( i
%10 == 9 ? " \\\n\t" : " " ),
910 backend
->GetFullName ( *objectFilename
).c_str () );
911 delete objectFilename
;
915 fprintf ( fMakefile
, "\n" );
917 if ( headers
.size () > 0 )
922 module
.name
.c_str (),
923 assignmentOperation
);
924 for ( i
= 0; i
< headers
.size (); i
++ )
929 ( i
%10 == 9 ? " \\\n\t" : " " ),
930 backend
->GetFullName ( *headers
[i
] ).c_str () );
933 fprintf ( fMakefile
, "\n" );
936 if ( mcheaders
.size () > 0 )
941 module
.name
.c_str (),
942 assignmentOperation
);
943 for ( i
= 0; i
< mcheaders
.size (); i
++ )
948 ( i
%10 == 9 ? " \\\n\t" : " " ),
949 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
952 fprintf ( fMakefile
, "\n" );
955 if ( mcresources
.size () > 0 )
960 module
.name
.c_str (),
961 assignmentOperation
);
962 for ( i
= 0; i
< mcresources
.size (); i
++ )
967 ( i
%10 == 9 ? " \\\n\t" : " " ),
968 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
969 delete mcresources
[i
];
971 fprintf ( fMakefile
, "\n" );
974 vector
<CompilationUnit
*> sourceCompilationUnits
;
975 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
976 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
978 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
979 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
983 objectsMacro
.c_str(),
984 backend
->GetFullName ( *object_file
).c_str () );
987 CleanupCompilationUnitVector ( sourceCompilationUnits
);
989 if ( IsSpecDefinitionFile() )
991 const FileLocation
*stubs_file
= new FileLocation(
992 IntermediateDirectory
,
993 module
.importLibrary
->source
->relative_path
,
994 ReplaceExtension ( module
.importLibrary
->source
->name
, "_" + module
.name
+ ".stubs.o" ) );
999 objectsMacro
.c_str(),
1000 backend
->GetFullName ( *stubs_file
).c_str () );
1006 /* caller needs to delete the returned object */
1008 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1010 if ( !module
.pch
|| !use_pch
)
1012 return new FileLocation ( IntermediateDirectory
,
1013 module
.pch
->file
->relative_path
+ "/.gch_" + module
.name
,
1014 module
.pch
->file
->name
+ ".gch" );
1017 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) $(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1018 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1019 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1020 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1021 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1023 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1024 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1026 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1027 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1029 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1030 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1031 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1032 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1033 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1035 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1036 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1037 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1038 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1040 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1041 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1042 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1043 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1044 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1046 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1047 "\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"
1048 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1049 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1050 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1051 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1052 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1053 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"
1055 "\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",
1056 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1057 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1058 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1059 Rule
winebuildPDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1061 "\t${gcc} -xc -E ${$(module_name)_RCFLAGS} $(source) > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec\n\n"
1062 "$(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"
1063 "\t$(ECHO_WINEBLD)\n"
1064 "\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",
1065 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec",
1066 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1067 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1068 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"
1069 "\t$(ECHO_WINEBLD)\n"
1070 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec --filename $(module_dllname)\n\n"
1071 "$(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"
1073 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1074 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec",
1075 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1076 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1077 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1078 Rule
winebuildDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1079 "\t$(ECHO_WINEBLD)\n"
1080 "\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",
1081 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
1082 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1083 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1084 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1085 "\t$(ECHO_WINEBLD)\n"
1086 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $@ --pedll $(source_path)$(SEP)$(source_name_noext).spec --filename $(module_dllname)\n"
1087 "$(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"
1089 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1090 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1091 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1092 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1093 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1094 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).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).h $(source)\n",
1097 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1098 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1099 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1100 "$(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"
1102 "\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"
1103 "$(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"
1105 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1106 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1107 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1108 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1109 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1110 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1111 "$(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"
1113 "\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"
1114 "$(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"
1116 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1117 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1118 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1119 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1120 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1121 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1122 "$(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"
1124 "\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"
1125 "$(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"
1127 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -fno-unit-at-a-time -c $<\n",
1128 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1129 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1130 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1131 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1132 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1133 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1135 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1136 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1137 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1138 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1140 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1141 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1142 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1143 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1145 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1146 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1147 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1148 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1150 "\t${gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1151 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1152 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1153 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1155 "\t${host_gpp} -o $@ $($(module_name)_CXXFLAGS)$(compiler_flags) -c $<\n",
1156 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1157 Rule
emptyRule ( "", NULL
);
1160 MingwModuleHandler::GenerateGccCommand (
1161 const FileLocation
* sourceFile
,
1163 const string
& extraDependencies
)
1165 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1166 string dependencies
= extraDependencies
;
1169 string extension
= GetExtension ( *sourceFile
);
1170 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1171 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1173 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1177 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1181 /* WIDL generated headers may be used */
1182 vector
<FileLocation
> rpcDependencies
;
1183 GetRpcHeaderDependencies ( rpcDependencies
);
1184 if ( rpcDependencies
.size () > 0 )
1185 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1187 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1191 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1193 const Property
* property
= module
.project
.LookupProperty(name
);
1196 return property
->value
;
1198 return string ( "" );
1201 /* caller needs to delete the returned object */
1203 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1205 string newname
= GetBasename ( base
->name
) + "_s.h";
1206 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1209 /* caller needs to delete the returned object */
1211 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1213 string newname
= GetBasename ( base
->name
) + "_c.h";
1214 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1217 /* caller needs to delete the returned object */
1219 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1221 string newname
= GetBasename ( base
->name
) + "_p.h";
1222 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1225 /* caller needs to delete the returned object */
1227 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1229 string newname
= GetBasename ( base
->name
) + ".h";
1230 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1233 /* caller needs to delete the returned object */
1235 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1237 string newname
= GetBasename ( base
->name
) + ".h";
1238 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1242 MingwModuleHandler::GenerateCommands (
1243 const CompilationUnit
& compilationUnit
,
1244 const string
& extraDependencies
)
1246 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1247 string extension
= GetExtension ( sourceFile
);
1248 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1257 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1258 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1259 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1260 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1261 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1262 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1263 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1264 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1265 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1266 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1267 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1268 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1269 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1270 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1271 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1272 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1273 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1274 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1275 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1278 Rule
*customRule
= NULL
;
1280 fprintf ( fMakefile
, "# COMMANDS\n" );
1282 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1284 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1286 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1288 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1290 customRule
= rules
[i
].rule
;
1294 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1296 GenerateGccCommand ( &sourceFile
,
1298 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1300 else if ( customRule
)
1301 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1304 throw InvalidOperationException ( __FILE__
,
1306 "Unsupported filename extension '%s' in file '%s'",
1308 backend
->GetFullName ( sourceFile
).c_str () );
1313 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1315 fprintf ( fMakefile
, "# BUILD MAP CODE\n" );
1317 fprintf ( fMakefile
,
1318 "ifeq ($(ROS_BUILDMAP),full)\n" );
1320 FileLocation
mapFilename ( OutputDirectory
,
1321 module
.output
->relative_path
,
1322 GetBasename ( module
.output
->name
) + ".map" );
1323 CLEAN_FILE ( mapFilename
);
1325 fprintf ( fMakefile
,
1326 "\t$(ECHO_OBJDUMP)\n" );
1327 fprintf ( fMakefile
,
1328 "\t$(Q)${objdump} -d -S %s > %s\n",
1329 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1330 backend
->GetFullName ( mapFilename
).c_str () );
1332 fprintf ( fMakefile
,
1334 fprintf ( fMakefile
,
1335 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1337 fprintf ( fMakefile
,
1339 fprintf ( fMakefile
,
1340 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1341 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1342 backend
->GetFullName ( mapFilename
).c_str () );
1344 fprintf ( fMakefile
,
1347 fprintf ( fMakefile
,
1352 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1354 fprintf ( fMakefile
, "# BUILD NO STRIP CODE\n" );
1356 fprintf ( fMakefile
,
1357 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1359 FileLocation
nostripFilename ( OutputDirectory
,
1360 module
.output
->relative_path
,
1361 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1362 CLEAN_FILE ( nostripFilename
);
1364 OutputCopyCommand ( *module
.output
, nostripFilename
);
1366 fprintf ( fMakefile
,
1371 MergeStringVector ( const Backend
* backend
,
1372 const vector
<FileLocation
>& input
,
1373 vector
<string
>& output
)
1377 int wrap_count
= -1;
1378 for ( size_t i
= 0; i
< input
.size (); i
++ )
1380 if ( wrap_count
++ == wrap_at
)
1382 output
.push_back ( s
);
1386 else if ( s
.size () > 0)
1388 s
+= backend
->GetFullName ( input
[i
] );
1390 if ( s
.length () > 0 )
1391 output
.push_back ( s
);
1395 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1396 vector
<FileLocation
>& objectFiles
) const
1398 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1400 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1401 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1402 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1403 objectFiles
.push_back ( *object_file
);
1409 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1411 if ( backend
->configuration
.CleanAsYouGo
)
1413 vector
<FileLocation
> objectFiles
;
1414 GetObjectsVector ( module
.non_if_data
,
1416 vector
<string
> lines
;
1417 MergeStringVector ( backend
,
1420 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1422 fprintf ( fMakefile
,
1423 "\t-@${rm} %s 2>$(NUL)\n",
1424 lines
[i
].c_str () );
1430 MingwModuleHandler::GenerateRunRsymCode () const
1432 fprintf ( fMakefile
, "# RUN RSYM CODE\n" );
1433 fprintf ( fMakefile
,
1434 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1435 fprintf ( fMakefile
,
1436 "\t$(ECHO_RSYM)\n" );
1437 fprintf ( fMakefile
,
1438 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1439 fprintf ( fMakefile
,
1444 MingwModuleHandler::GenerateRunStripCode () const
1446 fprintf ( fMakefile
, "# RUN STRIP CODE\n" );
1447 fprintf ( fMakefile
,
1448 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1449 fprintf ( fMakefile
,
1450 "\t$(ECHO_STRIP)\n" );
1451 fprintf ( fMakefile
,
1452 "\t${strip} -s -x -X $@\n\n" );
1453 fprintf ( fMakefile
,
1458 MingwModuleHandler::GenerateLinkerCommand (
1459 const string
& dependencies
,
1460 const string
& linkerParameters
,
1461 const string
& pefixupParameters
)
1463 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1464 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1465 string linker
= "${ld}";
1466 string objectsMacro
= GetObjectsMacro ( module
);
1467 string libsMacro
= GetLibsMacro ();
1469 fprintf ( fMakefile
, "# LINKER COMMAND\n" );
1471 string
target_macro ( GetTargetMacro ( module
) );
1472 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1474 string linkerScriptArgument
;
1475 if ( module
.linkerScript
!= NULL
)
1476 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1478 linkerScriptArgument
= "";
1480 /* check if we need to add default C++ libraries, ie if we have
1481 * a C++ user-mode module without the -nostdlib linker flag
1483 bool link_defaultlibs
= module
.cplusplus
&&
1484 linkerParameters
.find ("-nostdlib") == string::npos
&&
1485 !(module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
);
1487 if ( !module
.HasImportLibrary() )
1489 fprintf ( fMakefile
,
1490 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1491 target_macro
.c_str (),
1492 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1493 dependencies
.c_str (),
1494 target_folder
.c_str () );
1495 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1497 fprintf ( fMakefile
,
1498 "\t%s %s%s %s %s %s %s -o %s\n",
1500 linkerParameters
.c_str (),
1501 linkerScriptArgument
.c_str (),
1502 objectsMacro
.c_str (),
1503 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1505 GetLinkerMacro ().c_str (),
1506 target_macro
.c_str () );
1510 FileLocation
temp_exp ( IntermediateDirectory
,
1511 module
.output
->relative_path
,
1512 module
.name
+ ".exp" );
1513 CLEAN_FILE ( temp_exp
);
1515 fprintf ( fMakefile
,
1517 backend
->GetFullName ( temp_exp
).c_str (),
1518 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1519 backend
->GetFullPath ( temp_exp
).c_str () );
1520 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1522 fprintf ( fMakefile
,
1523 "\t${dlltool} --dllname %s --def %s --output-exp $@%s%s\n",
1524 module
.GetDllName ().c_str (),
1525 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1526 module
.mangledSymbols
? "" : " --kill-at",
1527 module
.underscoreSymbols
? " --add-underscore" : "" );
1529 fprintf ( fMakefile
,
1530 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1531 target_macro
.c_str (),
1532 backend
->GetFullName ( temp_exp
).c_str (),
1533 dependencies
.c_str (),
1534 target_folder
.c_str () );
1535 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1537 fprintf ( fMakefile
,
1538 "\t%s %s%s %s %s %s %s %s -o %s\n",
1541 linkerParameters
.c_str (),
1542 linkerScriptArgument
.c_str (),
1543 backend
->GetFullName ( temp_exp
).c_str (),
1544 objectsMacro
.c_str (),
1545 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1547 GetLinkerMacro ().c_str (),
1548 target_macro
.c_str () );
1550 fprintf ( fMakefile
,
1551 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1552 target_macro
.c_str (),
1553 pefixupParameters
.c_str() );
1556 GenerateBuildMapCode ();
1557 GenerateBuildNonSymbolStrippedCode ();
1558 GenerateRunRsymCode ();
1559 GenerateRunStripCode ();
1560 GenerateCleanObjectsAsYouGoCode ();
1562 if ( definitionFilename
)
1563 delete definitionFilename
;
1568 MingwModuleHandler::GeneratePhonyTarget() const
1570 string
targetMacro ( GetTargetMacro ( module
) );
1571 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1573 fprintf ( fMakefile
, "# PHONY TARGET\n" );
1574 fprintf ( fMakefile
,
1576 targetMacro
.c_str ());
1577 fprintf ( fMakefile
, "%s: | %s\n",
1578 targetMacro
.c_str (),
1579 backend
->GetFullPath ( *target_file
).c_str () );
1585 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1588 string moduleDependencies
;
1590 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1592 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1593 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1595 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1596 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1597 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1598 if ( GetExtension ( *objectFilename
) == ".h" )
1599 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1600 else if ( GetExtension ( *objectFilename
) == ".rc" )
1601 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1602 delete objectFilename
;
1605 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1607 GenerateCommands ( *compilationUnits
[i
],
1608 moduleDependencies
);
1609 fprintf ( fMakefile
,
1613 vector
<CompilationUnit
*> sourceCompilationUnits
;
1614 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1615 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1617 GenerateCommands ( *sourceCompilationUnits
[i
],
1618 moduleDependencies
);
1620 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1622 SpecFileType spec
= IsSpecDefinitionFile ();
1629 defRule
= &winebuildPRule
;
1631 defRule
= &winebuildRule
;
1633 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
1638 MingwModuleHandler::GenerateObjectFileTargets ()
1640 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1642 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1646 string cc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gcc}" : "${gcc}" );
1647 string cppc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gpp}" : "${gpp}" );
1649 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1650 CLEAN_FILE ( *pchFilename
);
1651 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1652 /* WIDL generated headers may be used */
1653 vector
<FileLocation
> rpcDependencies
;
1654 GetRpcHeaderDependencies ( rpcDependencies
);
1655 if ( rpcDependencies
.size () > 0 )
1656 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1657 fprintf ( fMakefile
,
1659 backend
->GetFullName ( *pchFilename
).c_str(),
1660 dependencies
.c_str(),
1661 backend
->GetFullPath ( *pchFilename
).c_str() );
1662 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1663 fprintf ( fMakefile
,
1664 "\t%s -o %s %s %s %s %s\n\n",
1665 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1666 backend
->GetFullName ( *pchFilename
).c_str(),
1667 module
.cplusplus
? cxxflagsMacro
.c_str() : cflagsMacro
.c_str(),
1668 GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, module
.cplusplus
? CompilerTypeCPP
: CompilerTypeCC
).c_str(),
1670 backend
->GetFullName ( baseHeaderFile
).c_str() );
1674 GenerateObjectFileTargets ( module
.non_if_data
);
1675 fprintf ( fMakefile
, "\n" );
1678 /* caller needs to delete the returned object */
1680 MingwModuleHandler::GenerateArchiveTarget ()
1682 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1683 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1685 fprintf ( fMakefile
, "# ARCHIVE TARGET\n" );
1687 if ( IsStaticLibrary ( module
) && definitionFilename
)
1689 arRule1
.Execute ( fMakefile
,
1694 backend
->GetFullName ( *definitionFilename
).c_str () );
1696 fprintf ( fMakefile
,
1697 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1698 module
.GetDllName ().c_str (),
1699 backend
->GetFullName ( *definitionFilename
).c_str (),
1700 module
.mangledSymbols
? "" : " --kill-at",
1701 module
.underscoreSymbols
? " --add-underscore" : "" );
1704 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1706 if ( definitionFilename
)
1707 delete definitionFilename
;
1709 if(module
.type
== HostStaticLibrary
)
1710 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1712 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1714 GenerateCleanObjectsAsYouGoCode ();
1716 fprintf ( fMakefile
, "\n" );
1718 return archiveFilename
;
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 commonflagsMacro
= ssprintf ("%s_COMMONFLAGS", module
.name
.c_str ());
1851 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1852 cxxflagsMacro
= ssprintf ("%s_CXXFLAGS", module
.name
.c_str ());
1853 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1854 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1855 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1856 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1857 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1858 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1863 &module
.linkerFlags
,
1866 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1868 GenerateMacros("+=", module
.project
.host_non_if_data
, NULL
, used_defs
);
1874 module
.project
.non_if_data
,
1879 if ( IsSpecDefinitionFile() )
1881 vector
<FileLocation
> s
;
1882 GetSpecImplibDependencies ( s
, module
.importLibrary
->source
);
1887 linkDepsMacro
.c_str() );
1888 for ( size_t i
= 0; i
< s
.size(); i
++ )
1889 fprintf ( fMakefile
,
1891 backend
->GetFullName ( s
[i
] ).c_str () );
1892 fprintf ( fMakefile
, "\n" );
1895 string globalCflags
= " ";
1896 globalCflags
+= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
1897 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1899 if ( module
.dynamicCRT
)
1900 globalCflags
+= " -D_DLL -D__USE_CRTIMP";
1903 globalCflags
+= " -Wall -Wpointer-arith";
1904 globalCflags
+= DEBUG_FORMAT
;
1905 if ( backend
->usePipe
)
1906 globalCflags
+= " -pipe";
1907 if ( !module
.allowWarnings
)
1908 globalCflags
+= " -Werror";
1909 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1911 if ( module
.cplusplus
)
1912 globalCflags
+= " $(HOST_CPPFLAGS)";
1914 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
1918 if ( module
.cplusplus
)
1920 globalCflags
+= " $(TARGET_CPPFLAGS)";
1923 globalCflags
+= " -nostdinc";
1926 // Always force disabling of sibling calls optimisation for GCC
1927 // (TODO: Move to version-specific once this bug is fixed in GCC)
1928 globalCflags
+= " -fno-optimize-sibling-calls";
1930 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1935 cflagsMacro
.c_str (),
1936 (" $(PROJECT_CFLAGS)" + globalCflags
).c_str () );
1941 cxxflagsMacro
.c_str (),
1942 (" $(PROJECT_CXXFLAGS)" + globalCflags
).c_str () );
1946 "%s += $(PROJECT_RCFLAGS)\n",
1947 windresflagsMacro
.c_str () );
1951 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
1952 widlflagsMacro
.c_str (),
1953 module
.output
->relative_path
.c_str () );
1957 "%s_LFLAGS := $(PROJECT_LFLAGS) $(%s_LFLAGS)\n",
1958 module
.name
.c_str (),
1959 module
.name
.c_str () );
1966 cflagsMacro
.c_str (),
1967 globalCflags
.c_str () );
1972 cxxflagsMacro
.c_str (),
1973 globalCflags
.c_str () );
1977 "%s_LFLAGS += $(HOST_LFLAGS)\n",
1978 module
.name
.c_str () );
1984 linkDepsMacro
.c_str (),
1985 libsMacro
.c_str () );
1987 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
1988 if ( strlen( cflags
) > 0 )
1990 fprintf ( fMakefile
,
1992 cflagsMacro
.c_str (),
1994 fprintf ( fMakefile
,
1996 cxxflagsMacro
.c_str (),
2000 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
2001 if ( strlen( nasmflags
) > 0 )
2003 fprintf ( fMakefile
,
2005 nasmflagsMacro
.c_str (),
2009 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
2010 if ( strlen( linkerflags
) > 0 )
2012 fprintf ( fMakefile
,
2014 linkerflagsMacro
.c_str (),
2018 fprintf ( fMakefile
, "\n\n" );
2020 // future references to the macros will be to get their values
2021 commonflagsMacro
= ssprintf ("$(%s)", commonflagsMacro
.c_str ());
2022 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2023 cxxflagsMacro
= ssprintf ("$(%s)", cxxflagsMacro
.c_str ());
2024 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2025 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2029 MingwModuleHandler::GenerateRules ()
2033 fprintf ( fMakefile
, "# RULES\n" );
2034 string targetMacro
= GetTargetMacro ( module
);
2035 //CLEAN_FILE ( targetMacro );
2036 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2038 // generate phony target for module name
2039 fprintf ( fMakefile
, ".PHONY: %s\n",
2040 module
.name
.c_str () );
2041 string dependencies
= GetTargetMacro ( module
);
2042 if ( module
.type
== Test
)
2043 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2044 fprintf ( fMakefile
, "%s: %s\n\n",
2045 module
.name
.c_str (),
2046 dependencies
.c_str () );
2047 if ( module
.type
== Test
)
2049 fprintf ( fMakefile
,
2051 targetMacro
.c_str ());
2054 if ( !ReferenceObjects ( module
) )
2056 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2061 spec
= IsSpecDefinitionFile();
2068 defRule
= &winebuildPDefRule
;
2070 defRule
= &winebuildDefRule
;
2072 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
2075 GenerateObjectFileTargets ();
2079 MingwModuleHandler::GetInvocationDependencies (
2080 const Module
& module
,
2081 string_list
& dependencies
)
2083 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2085 Invoke
& invoke
= *module
.invocations
[i
];
2086 if ( invoke
.invokeModule
== &module
)
2087 /* Protect against circular dependencies */
2089 invoke
.GetTargets ( dependencies
);
2094 MingwModuleHandler::GenerateInvocations () const
2096 if ( module
.invocations
.size () == 0 )
2099 fprintf ( fMakefile
, "# INVOCATIONS\n" );
2101 size_t iend
= module
.invocations
.size ();
2102 for ( size_t i
= 0; i
< iend
; i
++ )
2104 const Invoke
& invoke
= *module
.invocations
[i
];
2106 if ( invoke
.invokeModule
->type
!= BuildTool
)
2108 throw XMLInvalidBuildFileException (
2109 module
.node
.location
,
2110 "Only modules of type buildtool can be invoked." );
2113 string invokeTarget
= module
.GetInvocationTarget ( i
);
2114 string_list invoke_targets
;
2115 assert ( invoke_targets
.size() );
2116 invoke
.GetTargets ( invoke_targets
);
2117 fprintf ( fMakefile
,
2119 invokeTarget
.c_str () );
2120 fprintf ( fMakefile
,
2122 invokeTarget
.c_str () );
2123 size_t j
, jend
= invoke_targets
.size();
2124 for ( j
= 0; j
< jend
; j
++ )
2126 fprintf ( fMakefile
,
2128 invoke_targets
[i
].c_str () );
2130 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2131 for ( j
= 1; j
< jend
; j
++ )
2132 fprintf ( fMakefile
,
2134 invoke_targets
[i
].c_str () );
2135 fprintf ( fMakefile
,
2137 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2138 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2139 fprintf ( fMakefile
,
2141 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2142 invoke
.GetParameters ().c_str () );
2147 MingwModuleHandler::GetPreconditionDependenciesName () const
2149 return module
.name
+ "_precondition";
2153 MingwModuleHandler::GetDefaultDependencies (
2154 string_list
& dependencies
) const
2156 /* Avoid circular dependency */
2157 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2160 if (module
.name
!= "psdk" &&
2161 module
.name
!= "dxsdk")
2163 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2164 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2167 if (module
.name
!= "errcodes" &&
2168 module
.name
!= "bugcodes" &&
2169 module
.name
!= "ntstatus")
2171 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2172 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2173 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2176 ///* Check if any dependent library relies on the generated headers */
2177 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2179 // const Module& m = *module.project.modules[i];
2180 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2182 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2183 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2184 // string extension = GetExtension ( sourceFile );
2185 // if (extension == ".mc" || extension == ".MC" )
2187 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2188 // dependencies.push_back ( dependency );
2195 MingwModuleHandler::GeneratePreconditionDependencies ()
2197 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
2198 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2199 string_list dependencies
;
2200 GetDefaultDependencies ( dependencies
);
2201 GetModuleDependencies ( dependencies
);
2203 GetInvocationDependencies ( module
, dependencies
);
2205 if ( dependencies
.size() )
2207 fprintf ( fMakefile
,
2209 preconditionDependenciesName
.c_str () );
2210 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2211 fprintf ( fMakefile
,
2213 dependencies
[i
].c_str () );
2214 fprintf ( fMakefile
, "\n\n" );
2217 fprintf ( fMakefile
, "\n" );
2221 MingwModuleHandler::IsSpecDefinitionFile () const
2223 if(!module
.importLibrary
)
2226 std::string ext
= GetExtension ( *module
.importLibrary
->source
);
2228 if ( ext
== ".spec" )
2231 if ( ext
== ".pspec" )
2237 /* caller needs to delete the returned object */
2239 MingwModuleHandler::GetDefinitionFilename () const
2241 if ( module
.importLibrary
== NULL
)
2244 if ( IsSpecDefinitionFile () )
2246 return new FileLocation ( IntermediateDirectory
,
2247 module
.importLibrary
->source
->relative_path
,
2248 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2252 return new FileLocation ( SourceDirectory
,
2253 module
.importLibrary
->source
->relative_path
,
2254 module
.importLibrary
->source
->name
);
2259 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2261 if ( module
.importLibrary
!= NULL
)
2263 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2264 const FileLocation
*defFilename
= GetDefinitionFilename ();
2265 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2267 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE\n" );
2269 fprintf ( fMakefile
, "%s:",
2270 backend
->GetFullName ( *library_target
).c_str () );
2274 fprintf ( fMakefile
, " %s",
2275 backend
->GetFullName ( *defFilename
).c_str () );
2278 fprintf ( fMakefile
, " | %s\n",
2279 backend
->GetFullPath ( *library_target
).c_str () );
2281 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2283 fprintf ( fMakefile
,
2284 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2285 module
.GetDllName ().c_str (),
2286 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2288 backend
->GetFullName ( *library_target
).c_str (),
2289 module
.mangledSymbols
? "" : " --kill-at",
2290 module
.underscoreSymbols
? " --add-underscore" : "" );
2294 delete library_target
;
2299 MingwModuleHandler::GetSpecObjectDependencies (
2300 vector
<FileLocation
>& dependencies
,
2301 const FileLocation
*file
) const
2303 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2304 file
->relative_path
,
2305 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2309 MingwModuleHandler::GetSpecImplibDependencies (
2310 vector
<FileLocation
>& dependencies
,
2311 const FileLocation
*file
) const
2313 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2314 file
->relative_path
,
2315 GetBasename ( file
->name
) + "_" + module
.name
+ ".auto.def" ) );
2319 MingwModuleHandler::GetMcObjectDependencies (
2320 vector
<FileLocation
>& dependencies
,
2321 const FileLocation
*file
) const
2323 string basename
= GetBasename ( file
->name
);
2325 FileLocation
defDependency ( IntermediateDirectory
,
2328 dependencies
.push_back ( defDependency
);
2330 FileLocation
stubsDependency ( IntermediateDirectory
,
2331 file
->relative_path
,
2333 dependencies
.push_back ( stubsDependency
);
2337 MingwModuleHandler::GetWidlObjectDependencies (
2338 vector
<FileLocation
>& dependencies
,
2339 const FileLocation
*file
) const
2341 string basename
= GetBasename ( file
->name
);
2342 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2344 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2345 file
->relative_path
,
2346 basename
+ "_s.c" );
2347 dependencies
.push_back ( serverSourceDependency
);
2348 dependencies
.push_back ( *generatedHeaderFilename
);
2350 delete generatedHeaderFilename
;
2354 MingwModuleHandler::GetDefinitionDependencies (
2355 vector
<FileLocation
>& dependencies
) const
2357 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2358 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2360 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2361 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2362 string extension
= GetExtension ( sourceFile
);
2364 if (extension
== ".spec" || extension
== ".pspec")
2365 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2367 if (extension
== ".idl")
2369 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2370 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2375 enum DebugSupportType
2382 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2388 case DebugKernelMode
:
2389 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2393 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2400 module
.non_if_data
.libraries
.push_back(pLibrary
);
2404 MingwAddCRTLibrary( Module
&module
)
2406 const char * crtAttr
= module
.CRT
.c_str ();
2407 const char * crtLib
= NULL
;
2409 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2411 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2413 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2414 crtLib
= "libcntpr";
2415 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2420 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2422 if ( pLibrary
->importedModule
== NULL
)
2424 throw XMLInvalidBuildFileException (
2425 module
.node
.location
,
2426 "module '%s' trying to import non-existant C runtime module '%s'",
2427 module
.name
.c_str(),
2431 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2435 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2436 : MingwModuleHandler ( module_
)
2441 MingwBuildToolModuleHandler::Process ()
2443 GenerateBuildToolModuleTarget ();
2447 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2449 string
targetMacro ( GetTargetMacro (module
) );
2450 string objectsMacro
= GetObjectsMacro ( module
);
2451 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2452 string libsMacro
= GetLibsMacro ();
2456 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2459 if ( module
.cplusplus
)
2460 linker
= "${host_gpp}";
2462 linker
= "${host_gcc}";
2464 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2465 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2466 targetMacro
.c_str (),
2467 objectsMacro
.c_str (),
2468 linkDepsMacro
.c_str (),
2469 backend
->GetFullPath ( *target_file
).c_str () );
2470 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2471 fprintf ( fMakefile
,
2472 "\t%s %s -o $@ %s %s\n\n",
2474 GetLinkerMacro ().c_str (),
2475 objectsMacro
.c_str (),
2476 libsMacro
.c_str () );
2482 MingwKernelModuleHandler::MingwKernelModuleHandler (
2483 const Module
& module_
)
2485 : MingwModuleHandler ( module_
)
2490 MingwKernelModuleHandler::Process ()
2492 GenerateKernelModuleTarget ();
2496 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2498 string
targetMacro ( GetTargetMacro ( module
) );
2499 string workingDirectory
= GetWorkingDirectory ( );
2500 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2502 GenerateImportLibraryTargetIfNeeded ();
2504 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2508 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2510 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2511 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2512 module
.baseaddress
.c_str () );
2514 GenerateLinkerCommand ( dependencies
,
2515 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2520 GeneratePhonyTarget();
2525 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2526 const Module
& module_
)
2528 : MingwModuleHandler ( module_
)
2534 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2536 MingwAddCRTLibrary ( module
);
2537 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2541 MingwKernelModeDLLModuleHandler::Process ()
2543 GenerateKernelModeDLLModuleTarget ();
2547 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2549 string
targetMacro ( GetTargetMacro ( module
) );
2550 string workingDirectory
= GetWorkingDirectory ();
2551 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2553 GenerateImportLibraryTargetIfNeeded ();
2555 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2559 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2561 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2562 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2563 module
.baseaddress
.c_str () );
2564 GenerateLinkerCommand ( dependencies
,
2570 GeneratePhonyTarget();
2575 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2576 const Module
& module_
)
2578 : MingwModuleHandler ( module_
)
2583 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2585 MingwAddCRTLibrary ( module
);
2586 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2590 MingwNativeDLLModuleHandler::Process ()
2592 GenerateNativeDLLModuleTarget ();
2596 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2598 string
targetMacro ( GetTargetMacro (module
) );
2599 string workingDirectory
= GetWorkingDirectory ( );
2600 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2602 GenerateImportLibraryTargetIfNeeded ();
2604 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2608 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2610 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2611 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2612 module
.baseaddress
.c_str () );
2613 GenerateLinkerCommand ( dependencies
,
2619 GeneratePhonyTarget();
2624 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2625 const Module
& module_
)
2627 : MingwModuleHandler ( module_
)
2632 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2634 MingwAddCRTLibrary ( module
);
2635 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2639 MingwNativeCUIModuleHandler::Process ()
2641 GenerateNativeCUIModuleTarget ();
2645 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2647 string
targetMacro ( GetTargetMacro (module
) );
2648 string workingDirectory
= GetWorkingDirectory ( );
2649 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2651 GenerateImportLibraryTargetIfNeeded ();
2653 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2657 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2659 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2660 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2661 module
.baseaddress
.c_str () );
2662 GenerateLinkerCommand ( dependencies
,
2668 GeneratePhonyTarget();
2673 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2674 const Module
& module_
)
2676 : MingwModuleHandler ( module_
)
2680 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2681 const Module
& module_
)
2683 : MingwModuleHandler ( module_
)
2688 MingwAddImplicitLibraries( Module
&module
)
2692 if ( module
.type
!= Win32DLL
2693 && module
.type
!= Win32OCX
2694 && module
.type
!= Win32CUI
2695 && module
.type
!= Win32GUI
2696 && module
.type
!= Win32SCR
)
2701 if ( module
.isDefaultEntryPoint
)
2703 if ( module
.IsDLL () )
2705 pLibrary
= new Library ( module
, "mingw_dllmain" );
2706 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2710 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2711 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2715 pLibrary
= new Library ( module
, "mingw_common" );
2716 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2718 MingwAddCRTLibrary ( module
);
2719 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2723 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2725 MingwAddImplicitLibraries ( module
);
2729 MingwWin32DLLModuleHandler::Process ()
2731 GenerateWin32DLLModuleTarget ();
2735 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2737 string
targetMacro ( GetTargetMacro (module
) );
2738 string workingDirectory
= GetWorkingDirectory ( );
2739 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2741 GenerateImportLibraryTargetIfNeeded ();
2743 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2747 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2749 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2750 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2751 module
.baseaddress
.c_str () );
2752 GenerateLinkerCommand ( dependencies
,
2758 GeneratePhonyTarget();
2764 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2766 MingwAddImplicitLibraries ( module
);
2770 MingwWin32OCXModuleHandler::Process ()
2772 GenerateWin32OCXModuleTarget ();
2776 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2778 string
targetMacro ( GetTargetMacro (module
) );
2779 string workingDirectory
= GetWorkingDirectory ( );
2780 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2782 GenerateImportLibraryTargetIfNeeded ();
2784 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2788 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2790 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2791 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2792 module
.baseaddress
.c_str () );
2793 GenerateLinkerCommand ( dependencies
,
2799 GeneratePhonyTarget();
2804 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2805 const Module
& module_
)
2807 : MingwModuleHandler ( module_
)
2812 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2814 MingwAddImplicitLibraries ( module
);
2818 MingwWin32CUIModuleHandler::Process ()
2820 GenerateWin32CUIModuleTarget ();
2824 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2826 string
targetMacro ( GetTargetMacro (module
) );
2827 string workingDirectory
= GetWorkingDirectory ( );
2828 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2830 GenerateImportLibraryTargetIfNeeded ();
2832 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2836 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2838 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2839 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2840 module
.baseaddress
.c_str () );
2841 GenerateLinkerCommand ( dependencies
,
2847 GeneratePhonyTarget();
2852 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2853 const Module
& module_
)
2855 : MingwModuleHandler ( module_
)
2860 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2862 MingwAddImplicitLibraries ( module
);
2866 MingwWin32GUIModuleHandler::Process ()
2868 GenerateWin32GUIModuleTarget ();
2872 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2874 string
targetMacro ( GetTargetMacro (module
) );
2875 string workingDirectory
= GetWorkingDirectory ( );
2876 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2878 GenerateImportLibraryTargetIfNeeded ();
2880 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2884 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2886 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2887 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2888 module
.baseaddress
.c_str () );
2889 GenerateLinkerCommand ( dependencies
,
2895 GeneratePhonyTarget();
2900 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2901 const Module
& module_
)
2903 : MingwModuleHandler ( module_
)
2908 MingwBootLoaderModuleHandler::Process ()
2910 GenerateBootLoaderModuleTarget ();
2914 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2916 string
targetName ( module
.output
->name
);
2917 string
targetMacro ( GetTargetMacro (module
) );
2918 string workingDirectory
= GetWorkingDirectory ();
2919 FileLocation
junk_tmp ( TemporaryDirectory
,
2921 module
.name
+ ".junk.tmp" );
2922 CLEAN_FILE ( junk_tmp
);
2923 string objectsMacro
= GetObjectsMacro ( module
);
2924 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2928 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2930 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2931 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2932 targetMacro
.c_str (),
2933 objectsMacro
.c_str (),
2934 linkDepsMacro
.c_str (),
2935 backend
->GetFullPath ( *target_file
).c_str () );
2937 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2939 if (Environment::GetArch() == "arm")
2941 fprintf ( fMakefile
,
2942 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
2943 backend
->GetFullName ( junk_tmp
).c_str (),
2944 objectsMacro
.c_str (),
2945 linkDepsMacro
.c_str (),
2946 GetLinkerMacro ().c_str ());
2950 fprintf ( fMakefile
,
2951 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
2952 backend
->GetFullName ( junk_tmp
).c_str (),
2953 objectsMacro
.c_str (),
2954 linkDepsMacro
.c_str (),
2955 GetLinkerMacro ().c_str ());
2957 fprintf ( fMakefile
,
2958 "\t${objcopy} -O binary %s $@\n",
2959 backend
->GetFullName ( junk_tmp
).c_str () );
2960 GenerateBuildMapCode ( &junk_tmp
);
2961 fprintf ( fMakefile
,
2962 "\t-@${rm} %s 2>$(NUL)\n",
2963 backend
->GetFullName ( junk_tmp
).c_str () );
2969 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2970 const Module
& module_
)
2971 : MingwModuleHandler ( module_
)
2976 MingwBootProgramModuleHandler::Process ()
2978 GenerateBootProgramModuleTarget ();
2982 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2984 string
targetName ( module
.output
->name
);
2985 string
targetMacro ( GetTargetMacro (module
) );
2986 string workingDirectory
= GetWorkingDirectory ();
2987 FileLocation
junk_tmp ( TemporaryDirectory
,
2989 module
.name
+ ".junk.tmp" );
2990 FileLocation
junk_elf ( TemporaryDirectory
,
2992 module
.name
+ ".junk.elf" );
2993 FileLocation
junk_cpy ( TemporaryDirectory
,
2995 module
.name
+ ".junk.elf" );
2996 CLEAN_FILE ( junk_tmp
);
2997 CLEAN_FILE ( junk_elf
);
2998 CLEAN_FILE ( junk_cpy
);
2999 string objectsMacro
= GetObjectsMacro ( module
);
3000 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3001 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3005 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
3007 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3008 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3009 targetMacro
.c_str (),
3010 objectsMacro
.c_str (),
3011 linkDepsMacro
.c_str (),
3012 payload
->name
.c_str (),
3013 backend
->GetFullPath ( *target_file
).c_str () );
3015 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3017 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3018 module
.buildtype
.c_str (),
3019 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3020 backend
->GetFullName ( junk_cpy
).c_str () );
3022 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3023 module
.buildtype
.c_str (),
3024 backend
->GetFullName ( junk_cpy
).c_str (),
3025 backend
->GetFullName ( junk_tmp
).c_str () );
3027 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
3028 module
.buildtype
.c_str (),
3029 linkDepsMacro
.c_str (),
3030 backend
->GetFullName ( junk_tmp
).c_str (),
3031 backend
->GetFullName ( junk_elf
).c_str () );
3033 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3034 module
.buildtype
.c_str (),
3035 backend
->GetFullName ( junk_elf
).c_str (),
3036 backend
->GetFullName ( *module
.output
) .c_str () );
3038 fprintf ( fMakefile
,
3039 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3040 backend
->GetFullName ( junk_tmp
).c_str (),
3041 backend
->GetFullName ( junk_elf
).c_str (),
3042 backend
->GetFullName ( junk_cpy
).c_str () );
3048 MingwIsoModuleHandler::MingwIsoModuleHandler (
3049 const Module
& module_
)
3051 : MingwModuleHandler ( module_
)
3056 MingwIsoModuleHandler::Process ()
3058 GenerateIsoModuleTarget ();
3062 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3063 const string
& bootcdDirectory
)
3065 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3067 const Module
& m
= *p
->second
;
3070 if ( m
.bootstrap
!= NULL
)
3072 FileLocation
targetFile ( OutputDirectory
,
3073 m
.bootstrap
->base
.length () > 0
3074 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3076 m
.bootstrap
->nameoncd
);
3077 OutputCopyCommand ( *m
.output
, targetFile
);
3083 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3084 const string
& bootcdDirectory
)
3086 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3088 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3089 FileLocation
targetFile ( OutputDirectory
,
3090 cdfile
.target
->relative_path
.length () > 0
3091 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3093 cdfile
.target
->name
);
3094 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3099 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3100 const string
& bootcdDirectory
)
3102 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3104 const Module
& m
= *p
->second
;
3107 if ( m
.bootstrap
!= NULL
)
3109 FileLocation
targetDirectory ( OutputDirectory
,
3110 m
.bootstrap
->base
.length () > 0
3111 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3114 out
.push_back ( targetDirectory
);
3120 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3121 const string
& bootcdDirectory
)
3123 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3125 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3126 FileLocation
targetDirectory ( OutputDirectory
,
3127 cdfile
.target
->relative_path
.length () > 0
3128 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3131 out
.push_back( targetDirectory
);
3136 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3137 const string
& bootcdDirectory
)
3139 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3140 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3144 MingwIsoModuleHandler::GetBootstrapCdFiles (
3145 vector
<FileLocation
>& out
) const
3147 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3149 const Module
& m
= *p
->second
;
3152 if ( m
.bootstrap
!= NULL
)
3154 out
.push_back ( *m
.output
);
3160 MingwIsoModuleHandler::GetNonModuleCdFiles (
3161 vector
<FileLocation
>& out
) const
3163 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3165 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3166 out
.push_back ( *cdfile
.source
);
3171 MingwIsoModuleHandler::GetCdFiles (
3172 vector
<FileLocation
>& out
) const
3174 GetBootstrapCdFiles ( out
);
3175 GetNonModuleCdFiles ( out
);
3179 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3181 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
3182 string bootcdDirectory
= "cd";
3183 FileLocation
bootcd ( OutputDirectory
,
3186 FileLocation
bootcdReactos ( OutputDirectory
,
3187 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3189 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3190 vector
<FileLocation
> vCdDirectories
;
3193 FileLocation
srcunattend ( SourceDirectory
,
3194 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3196 FileLocation
tarunattend ( bootcdReactos
.directory
,
3197 bootcdReactos
.relative_path
,
3199 if (module
.type
== IsoRegTest
)
3200 vSourceFiles
.push_back ( srcunattend
);
3203 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3207 throw InvalidOperationException ( module
.node
.location
.c_str(),
3209 "Invalid bootsector. module '%s' requires <bootsector>",
3210 module
.name
.c_str ());
3213 const FileLocation
*isoboot
= bootModule
->output
;
3214 vSourceFiles
.push_back ( *isoboot
);
3216 // prepare reactos.dff and reactos.inf
3217 FileLocation
reactosDff ( SourceDirectory
,
3218 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3220 FileLocation
reactosInf ( bootcdReactos
.directory
,
3221 bootcdReactos
.relative_path
,
3224 vSourceFiles
.push_back ( reactosDff
);
3227 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3228 Iso/LiveIso outputs are generated in code base root
3230 string IsoName
= module
.output
->name
;
3232 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3235 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3236 GetCdFiles ( vCdFiles
);
3237 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3238 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3240 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3241 module
.name
.c_str ());
3242 fprintf ( fMakefile
,
3243 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3244 module
.name
.c_str (),
3245 backend
->GetFullName ( *isoboot
).c_str (),
3246 sourceFiles
.c_str (),
3248 cdDirectories
.c_str () );
3249 fprintf ( fMakefile
,
3250 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3251 backend
->GetFullName ( reactosDff
).c_str (),
3252 backend
->GetFullPath ( bootcdReactos
).c_str () );
3253 fprintf ( fMakefile
,
3254 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3255 backend
->GetFullName ( reactosDff
).c_str (),
3256 backend
->GetFullName ( reactosInf
).c_str (),
3257 backend
->GetFullPath ( bootcdReactos
).c_str ());
3258 fprintf ( fMakefile
,
3259 "\t-@${rm} %s 2>$(NUL)\n",
3260 backend
->GetFullName ( reactosInf
).c_str () );
3261 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3262 OutputCdfileCopyCommands ( bootcdDirectory
);
3264 if (module
.type
== IsoRegTest
)
3265 OutputCopyCommand ( srcunattend
, tarunattend
);
3267 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3268 fprintf ( fMakefile
,
3269 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3270 backend
->GetFullName ( *isoboot
).c_str (),
3271 backend
->GetFullPath ( bootcd
).c_str (),
3273 fprintf ( fMakefile
,
3278 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3279 const Module
& module_
)
3281 : MingwModuleHandler ( module_
)
3286 MingwLiveIsoModuleHandler::Process ()
3288 GenerateLiveIsoModuleTarget ();
3292 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3294 FileLocation
dir ( OutputDirectory
,
3297 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3301 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3302 string
& reactosDirectory
)
3304 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3306 const Module
& m
= *p
->second
;
3311 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3312 FileLocation
destination ( OutputDirectory
,
3313 m
.install
->relative_path
.length () > 0
3314 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3315 : livecdDirectory
+ sSep
+ reactosDirectory
,
3317 OutputCopyCommand ( *aliasedModule
.output
,
3324 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3325 string
& reactosDirectory
)
3327 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3329 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3330 FileLocation
target ( OutputDirectory
,
3331 installfile
.target
->relative_path
.length () > 0
3332 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3333 : livecdDirectory
+ sSep
+ reactosDirectory
,
3334 installfile
.target
->name
);
3335 OutputCopyCommand ( *installfile
.source
, target
);
3340 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3342 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3343 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3344 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3345 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3346 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3347 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3349 FileLocation
livecdIni ( SourceDirectory
,
3350 "boot" + sSep
+ "bootdata",
3352 FileLocation
destination ( OutputDirectory
,
3355 OutputCopyCommand ( livecdIni
,
3360 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3362 FileLocation
freeldr ( OutputDirectory
,
3363 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3365 FileLocation
destination ( OutputDirectory
,
3366 livecdDirectory
+ sSep
+ "loader",
3368 OutputCopyCommand ( freeldr
,
3373 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3375 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
3376 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3377 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3379 fprintf ( fMakefile
,
3380 "\t$(ECHO_MKHIVE)\n" );
3381 fprintf ( fMakefile
,
3382 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3383 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3384 cSep
, cSep
, cSep
, cSep
);
3388 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3390 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3391 string livecdDirectory
= module
.name
;
3392 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3397 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3401 throw InvalidOperationException ( module
.node
.location
.c_str(),
3403 "Invalid bootsector. module '%s' requires <bootsector>",
3404 module
.name
.c_str ());
3407 const FileLocation
*isoboot
= bootModule
->output
;
3410 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3411 Iso/LiveIso outputs are generated in code base root
3413 IsoName
= module
.output
->name
;
3415 string reactosDirectory
= "reactos";
3416 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3417 FileLocation
livecdReactos ( OutputDirectory
,
3418 livecdReactosNoFixup
,
3420 CLEAN_FILE ( livecdReactos
);
3422 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3423 module
.name
.c_str ());
3424 fprintf ( fMakefile
,
3425 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3426 module
.name
.c_str (),
3427 backend
->GetFullName ( *isoboot
) .c_str (),
3428 backend
->GetFullPath ( livecdReactos
).c_str () );
3429 OutputModuleCopyCommands ( livecdDirectory
,
3431 OutputNonModuleCopyCommands ( livecdDirectory
,
3433 OutputProfilesDirectoryCommands ( livecdDirectory
);
3434 OutputLoaderCommands ( livecdDirectory
);
3435 OutputRegistryCommands ( livecdDirectory
);
3436 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3437 fprintf ( fMakefile
,
3438 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3439 backend
->GetFullName( *isoboot
).c_str (),
3440 backend
->GetFullPath ( livecd
).c_str (),
3442 fprintf ( fMakefile
,
3447 MingwTestModuleHandler::MingwTestModuleHandler (
3448 const Module
& module_
)
3450 : MingwModuleHandler ( module_
)
3455 MingwTestModuleHandler::Process ()
3457 GenerateTestModuleTarget ();
3460 /* caller needs to delete the returned object */
3462 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3464 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3465 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3466 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3470 MingwTestModuleHandler::GenerateTestModuleTarget ()
3472 string
targetMacro ( GetTargetMacro ( module
) );
3473 string workingDirectory
= GetWorkingDirectory ( );
3474 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3476 GenerateImportLibraryTargetIfNeeded ();
3478 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3482 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3484 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3485 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3486 module
.baseaddress
.c_str () );
3487 GenerateLinkerCommand ( dependencies
,
3493 GeneratePhonyTarget();
3498 MingwAliasModuleHandler::MingwAliasModuleHandler (
3499 const Module
& module_
)
3501 : MingwModuleHandler ( module_
)
3506 MingwAliasModuleHandler::Process ()
3511 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3512 const Module
& module_
)
3514 : MingwModuleHandler ( module_
)
3519 MingwCabinetModuleHandler::Process ()
3521 string
targetMacro ( GetTargetMacro (module
) );
3525 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3526 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3527 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3528 targetMacro
.c_str (),
3529 backend
->GetFullPath ( *target_file
).c_str () );
3531 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3532 fprintf ( fMakefile
,
3533 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3534 targetMacro
.c_str (),
3535 module
.name
.c_str());
3538 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3539 const Module
& module_
)
3541 : MingwModuleHandler ( module_
)
3546 MingwElfExecutableModuleHandler::Process ()
3548 string
targetName ( module
.output
->name
);
3549 string
targetMacro ( GetTargetMacro (module
) );
3550 string workingDirectory
= GetWorkingDirectory ();
3551 string objectsMacro
= GetObjectsMacro ( module
);
3552 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3553 string libsMacro
= GetLibsMacro ();
3557 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3558 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3559 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3560 targetMacro
.c_str (),
3561 objectsMacro
.c_str (),
3562 linkDepsMacro
.c_str (),
3563 backend
->GetFullPath ( *target_file
).c_str () );
3565 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3567 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s %s -o %s\n",
3568 module
.buildtype
.c_str(),
3569 objectsMacro
.c_str(),
3572 targetMacro
.c_str () );