2 * Copyright (C) 2005 Casper S. Hornstrup
3 * 2007-2008 Hervé Poussineau
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "../../pch.h"
23 #include "../../rbuild.h"
25 #include "modulehandler.h"
32 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
33 #define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
36 MingwModuleHandler::backend
= NULL
;
38 MingwModuleHandler::fMakefile
= NULL
;
42 const string
& filename
,
43 const string
& prefix
)
45 if ( !prefix
.length() )
48 const char* pfilename
= filename
.c_str();
49 const char* p1
= strrchr ( pfilename
, '/' );
50 const char* p2
= strrchr ( pfilename
, '\\' );
55 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
58 out
+= prefix
+ pfilename
;
63 GetTargetMacro ( const Module
& module
, bool with_dollar
)
65 string
s ( module
.name
);
69 return ssprintf ( "$(%s)", s
.c_str() );
73 MingwModuleHandler::MingwModuleHandler (
74 const Module
& module_
)
81 MingwModuleHandler::~MingwModuleHandler()
86 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
92 MingwModuleHandler::SetMakefile ( FILE* f
)
98 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
103 /*static*/ const FileLocation
*
104 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
106 switch ( file
->directory
)
108 case SourceDirectory
:
110 case IntermediateDirectory
:
111 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
113 case OutputDirectory
:
114 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
116 case InstallDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
120 throw InvalidOperationException ( __FILE__
,
122 "Invalid directory %d.",
129 /* caller needs to delete the returned object */
131 MingwModuleHandler::GetTargetFilename (
132 const Module
& module
,
133 string_list
* pclean_files
)
135 FileLocation
*target
= new FileLocation ( *module
.output
);
138 string_list
& clean_files
= *pclean_files
;
139 CLEAN_FILE ( *target
);
144 /* caller needs to delete the returned object */
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 FileLocation
*target
= new FileLocation ( *module
.dependency
);
153 string_list
& clean_files
= *pclean_files
;
154 CLEAN_FILE ( *target
);
159 /* caller needs to delete the returned object */
161 MingwModuleHandler::InstanciateHandler (
162 const Module
& module
,
163 MingwBackend
* backend
)
165 MingwModuleHandler
* handler
;
166 switch ( module
.type
)
169 handler
= new MingwBuildToolModuleHandler ( module
);
172 handler
= new MingwStaticLibraryModuleHandler ( module
);
174 case HostStaticLibrary
:
175 handler
= new MingwHostStaticLibraryModuleHandler ( module
);
178 handler
= new MingwObjectLibraryModuleHandler ( module
);
181 handler
= new MingwKernelModuleHandler ( module
);
184 handler
= new MingwNativeCUIModuleHandler ( module
);
187 handler
= new MingwWin32CUIModuleHandler ( module
);
191 handler
= new MingwWin32GUIModuleHandler ( module
);
195 handler
= new MingwKernelModeDLLModuleHandler ( module
);
198 handler
= new MingwNativeDLLModuleHandler ( module
);
201 handler
= new MingwWin32DLLModuleHandler ( module
);
204 handler
= new MingwWin32OCXModuleHandler ( module
);
206 case KernelModeDriver
:
207 handler
= new MingwKernelModeDriverModuleHandler ( module
);
210 handler
= new MingwBootLoaderModuleHandler ( module
);
213 handler
= new MingwBootSectorModuleHandler ( module
);
216 handler
= new MingwBootProgramModuleHandler ( module
);
219 handler
= new MingwIsoModuleHandler ( module
);
222 handler
= new MingwLiveIsoModuleHandler ( module
);
225 handler
= new MingwIsoModuleHandler ( module
);
228 handler
= new MingwLiveIsoModuleHandler ( module
);
231 handler
= new MingwTestModuleHandler ( module
);
234 handler
= new MingwRpcServerModuleHandler ( module
);
237 handler
= new MingwRpcClientModuleHandler ( module
);
240 handler
= new MingwRpcProxyModuleHandler ( module
);
243 handler
= new MingwAliasModuleHandler ( module
);
246 handler
= new MingwMessageHeaderModuleHandler (module
);
249 handler
= new MingwIdlHeaderModuleHandler ( module
);
252 handler
= new MingwCabinetModuleHandler ( module
);
254 case EmbeddedTypeLib
:
255 handler
= new MingwEmbeddedTypeLibModuleHandler ( module
);
258 handler
= new MingwElfExecutableModuleHandler ( module
);
261 throw UnknownModuleTypeException (
262 module
.node
.location
,
270 MingwModuleHandler::GetWorkingDirectory () const
276 MingwModuleHandler::GetBasename ( const string
& filename
) const
278 size_t index
= filename
.find_last_of ( '.' );
279 if ( index
!= string::npos
)
280 return filename
.substr ( 0, index
);
285 MingwModuleHandler::GetExtraDependencies (
286 const FileLocation
*file
) const
288 string extension
= GetExtension ( *file
);
289 if ( extension
== ".idl" || extension
== ".IDL" )
291 const FileLocation
*header
;
292 switch ( module
.type
)
294 case RpcServer
: header
= GetRpcServerHeaderFilename ( file
); break;
295 case RpcClient
: header
= GetRpcClientHeaderFilename ( file
); break;
296 case RpcProxy
: header
= GetRpcProxyHeaderFilename ( file
); break;
297 case IdlHeader
: header
= GetIdlHeaderFilename ( file
); break;
298 default: header
= NULL
; break;
303 string dependencies
= backend
->GetFullName ( *header
);
305 return " " + dependencies
;
312 MingwModuleHandler::GetCompilationUnitDependencies (
313 const CompilationUnit
& compilationUnit
) const
315 if ( compilationUnit
.GetFiles ().size () <= 1 )
317 vector
<string
> sourceFiles
;
318 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
320 const File
& file
= *compilationUnit
.GetFiles ()[i
];
321 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
323 return string ( " " ) + v2s ( sourceFiles
, 10 );
326 /* caller needs to delete the returned object */
328 MingwModuleHandler::GetModuleArchiveFilename () const
330 if ( IsStaticLibrary ( module
) )
331 return GetTargetFilename ( module
, NULL
);
332 return new FileLocation ( IntermediateDirectory
,
333 module
.output
->relative_path
,
334 ReplaceExtension ( module
.name
, ".temp.a" ) );
338 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
340 string extension
= GetExtension ( file
.file
);
341 return ( extension
== ".spec" || extension
== ".SPEC" );
345 MingwModuleHandler::ReferenceObjects (
346 const Module
& module
)
348 if ( module
.type
== ObjectLibrary
)
350 if ( module
.type
== RpcServer
)
352 if ( module
.type
== RpcClient
)
354 if ( module
.type
== RpcProxy
)
356 if ( module
.type
== IdlHeader
)
358 if ( module
.type
== MessageHeader
)
364 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
365 const FileLocation
& destination
)
370 "\t${cp} %s %s 1>$(NUL)\n",
371 backend
->GetFullName ( source
).c_str (),
372 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
376 MingwModuleHandler::GetImportLibraryDependency (
377 const Module
& importedModule
)
380 if ( ReferenceObjects ( importedModule
) )
382 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
385 dep
= GetTargetMacro ( importedModule
);
386 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
388 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
389 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
390 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
391 if ( GetExtension ( *objectFilename
) == ".h" )
392 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
393 else if ( GetExtension ( *objectFilename
) == ".rc" )
394 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
399 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
400 dep
= backend
->GetFullName ( *library_target
);
401 delete library_target
;
407 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
408 string_list
& targets
)
410 if ( dependencyModule
.invocations
.size () > 0 )
412 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
414 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
415 invoke
.GetTargets ( targets
);
419 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
423 MingwModuleHandler::GetModuleDependencies (
424 string_list
& dependencies
)
426 size_t iend
= module
.dependencies
.size ();
431 for ( size_t i
= 0; i
< iend
; i
++ )
433 const Dependency
& dependency
= *module
.dependencies
[i
];
434 const Module
& dependencyModule
= *dependency
.dependencyModule
;
435 GetTargets ( dependencyModule
,
438 vector
<FileLocation
> v
;
439 GetDefinitionDependencies ( v
);
441 for ( size_t i
= 0; i
< v
.size (); i
++ )
443 const FileLocation
& file
= v
[i
];
444 dependencies
.push_back ( backend
->GetFullName ( file
) );
448 /* caller needs to delete the returned object */
450 MingwModuleHandler::GetObjectFilename (
451 const FileLocation
* sourceFile
,
452 const Module
& module
) const
454 DirectoryLocation destination_directory
;
456 string extension
= GetExtension ( *sourceFile
);
458 if ( module
.type
== BootSector
)
459 return new FileLocation ( *module
.output
);
460 else if ( extension
== ".rc" || extension
== ".RC" )
461 newExtension
= "_" + module
.name
+ ".coff";
462 else if ( extension
== ".mc" || extension
== ".MC" )
463 newExtension
= ".rc";
464 else if ( extension
== ".spec" || extension
== ".SPEC" )
465 newExtension
= ".stubs.o";
466 else if ( extension
== ".idl" || extension
== ".IDL" )
468 if ( module
.type
== RpcServer
)
469 newExtension
= "_s.o";
470 else if ( module
.type
== RpcClient
)
471 newExtension
= "_c.o";
472 else if ( module
.type
== RpcProxy
)
473 newExtension
= "_p.o";
478 newExtension
= "_" + module
.name
+ ".o";
480 if ( module
.type
== BootSector
)
481 destination_directory
= OutputDirectory
;
483 destination_directory
= IntermediateDirectory
;
485 const FileLocation
*obj_file
= new FileLocation(
486 destination_directory
,
487 sourceFile
->relative_path
,
488 ReplaceExtension ( sourceFile
->name
, newExtension
) );
489 PassThruCacheDirectory ( obj_file
);
495 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
497 return module
.name
+ "_clean";
501 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
503 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
505 Library
& library
= *module
.non_if_data
.libraries
[i
];
506 if ( library
.importedModule
->type
== ObjectLibrary
)
507 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
512 MingwModuleHandler::GenerateCleanTarget () const
514 if ( module
.type
== Alias
)
518 ".PHONY: %s_clean\n",
519 module
.name
.c_str() );
520 vector
<string
> referencedModuleNames
;
521 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
524 GetModuleCleanTarget ( module
).c_str(),
525 v2s ( referencedModuleNames
, 10 ).c_str () );
526 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
528 if ( ( i
+ 1 ) % 10 == 9 )
529 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
530 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
532 fprintf ( fMakefile
, " 2>$(NUL)\n" );
534 if( ProxyMakefile::GenerateProxyMakefile(module
) )
536 DirectoryLocation root
;
538 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
539 root
= SourceDirectory
;
541 root
= OutputDirectory
;
543 FileLocation
proxyMakefile ( root
,
544 module
.output
->relative_path
,
546 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
547 backend
->GetFullName ( proxyMakefile
).c_str () );
550 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
554 MingwModuleHandler::GenerateInstallTarget () const
556 if ( !module
.install
)
558 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
561 module
.name
.c_str (),
562 backend
->GetFullName ( *module
.install
).c_str () );
566 MingwModuleHandler::GenerateDependsTarget () const
569 ".PHONY: %s_depends\n",
570 module
.name
.c_str() );
572 "%s_depends: $(RBUILD_TARGET)\n",
573 module
.name
.c_str () );
575 "\t$(ECHO_RBUILD)\n" );
577 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
578 module
.name
.c_str () );
582 MingwModuleHandler::GetObjectFilenames ()
584 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
585 if ( compilationUnits
.size () == 0 )
588 string
objectFilenames ( "" );
589 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
591 if ( objectFilenames
.size () > 0 )
592 objectFilenames
+= " ";
593 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
594 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
595 objectFilenames
+= backend
->GetFullName ( *object_file
);
598 return objectFilenames
;
602 MingwModuleHandler::GenerateGccDefineParametersFromVector (
603 const vector
<Define
*>& defines
,
604 set
<string
>& used_defs
)
608 for ( size_t i
= 0; i
< defines
.size (); i
++ )
610 Define
& define
= *defines
[i
];
611 if (used_defs
.find(define
.name
) != used_defs
.end())
613 if (parameters
.length () > 0)
615 if (define
.name
.find('(') != string::npos
)
616 parameters
+= "$(QT)";
618 parameters
+= define
.name
;
619 if (define
.value
.length () > 0)
622 parameters
+= define
.value
;
624 if (define
.name
.find('(') != string::npos
)
625 parameters
+= "$(QT)";
626 used_defs
.insert(used_defs
.begin(),define
.name
);
632 MingwModuleHandler::GenerateGccDefineParameters () const
634 set
<string
> used_defs
;
635 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
, used_defs
);
636 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
, used_defs
);
637 if ( s
.length () > 0 )
646 MingwModuleHandler::ConcatenatePaths (
648 const string
& path2
) const
650 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
652 if ( path1
[path1
.length ()] == cSep
)
653 return path1
+ path2
;
655 return path1
+ cSep
+ path2
;
659 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
661 string parameters
, path_prefix
;
662 for ( size_t i
= 0; i
< includes
.size (); i
++ )
664 Include
& include
= *includes
[i
];
665 if ( parameters
.length () > 0 )
667 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
673 MingwModuleHandler::GenerateGccIncludeParameters () const
675 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
676 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
677 if ( s
.length () > 0 )
686 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
689 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
691 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
692 if ( compilerFlag
.compiler
== type
)
693 parameters
+= " " + compilerFlag
.flag
;
699 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
702 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
704 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
705 if ( parameters
.length () > 0 )
707 parameters
+= linkerFlag
.flag
;
713 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
714 const vector
<Library
*>& libraries
)
716 string
dependencies ( "" );
718 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
720 if ( wrap_count
++ == 5 )
721 dependencies
+= " \\\n\t\t", wrap_count
= 0;
722 else if ( dependencies
.size () > 0 )
724 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
730 MingwModuleHandler::GenerateLinkerParameters () const
732 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
736 MingwModuleHandler::GenerateMacro (
737 const char* assignmentOperation
,
739 const IfableData
& data
,
740 set
<const Define
*> *used_defs
,
741 bool generatingCompilerMacro
)
744 bool generateAssignment
;
746 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
747 if ( generatingCompilerMacro
)
748 generateAssignment
|= data
.compilerFlags
.size () > 0;
749 if ( generateAssignment
)
754 assignmentOperation
);
757 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
762 backend
->GetFullPath ( *pchFilename
).c_str () );
766 if ( generatingCompilerMacro
)
768 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
769 if ( compilerParameters
.size () > 0 )
774 compilerParameters
.c_str () );
777 for ( i
= 0; i
< data
.includes
.size(); i
++ )
779 const Include
& include
= *data
.includes
[i
];
780 const FileLocation
* includeDirectory
= include
.directory
;
784 backend
->GetFullPath ( *includeDirectory
).c_str() );
786 for ( i
= 0; i
< data
.defines
.size(); i
++ )
788 const Define
& define
= *data
.defines
[i
];
791 set
<const Define
*>::const_iterator last_define
;
792 for (last_define
= used_defs
->begin ();
793 last_define
!= used_defs
->end ();
796 if ( (*last_define
)->name
!= define
.name
)
798 if ( !define
.overridable
)
800 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
802 "Invalid override of define '%s', already defined at %s",
803 define
.name
.c_str (),
804 define
.node
->location
.c_str () );
806 if ( backend
->configuration
.Verbose
)
807 printf("%s: Overriding '%s' already defined at %s\n",
808 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
809 define
.node
->location
.c_str () );
812 if ( last_define
!= used_defs
->end () )
818 define
.name
.c_str() );
819 if (define
.value
.length () > 0)
823 define
.value
.c_str() );
825 used_defs
->insert( used_defs
->begin (), &define
);
827 if ( generateAssignment
)
829 fprintf ( fMakefile
, "\n" );
834 MingwModuleHandler::GenerateMacros (
835 const char* assignmentOperation
,
836 const IfableData
& data
,
837 const vector
<LinkerFlag
*>* linkerFlags
,
838 set
<const Define
*>& used_defs
)
842 GenerateMacro ( assignmentOperation
,
847 GenerateMacro ( assignmentOperation
,
853 if ( linkerFlags
!= NULL
)
855 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
856 if ( linkerParameters
.size () > 0 )
861 linkerflagsMacro
.c_str (),
863 linkerParameters
.c_str() );
867 if ( data
.libraries
.size () > 0 )
869 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
870 if ( deps
.size () > 0 )
881 const vector
<If
*>& ifs
= data
.ifs
;
882 for ( i
= 0; i
< ifs
.size(); i
++ )
885 if ( rIf
.data
.defines
.size()
886 || rIf
.data
.includes
.size()
887 || rIf
.data
.libraries
.size()
888 || rIf
.data
.compilationUnits
.size()
889 || rIf
.data
.compilerFlags
.size()
890 || rIf
.data
.ifs
.size() )
894 "%s (\"$(%s)\",\"%s\")\n",
895 rIf
.negated
? "ifneq" : "ifeq",
896 rIf
.property
.c_str(),
911 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
913 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
914 delete compilationUnits
[i
];
918 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
923 MingwModuleHandler::GenerateSourceMacros (
924 const char* assignmentOperation
,
925 const IfableData
& data
)
929 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
930 vector
<const FileLocation
*> headers
;
931 if ( compilationUnits
.size () > 0 )
936 sourcesMacro
.c_str (),
937 assignmentOperation
);
938 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
940 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
941 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
945 ( i
%10 == 9 ? " \\\n\t" : " " ),
946 backend
->GetFullName ( compilationName
).c_str () );
948 fprintf ( fMakefile
, "\n" );
951 const vector
<If
*>& ifs
= data
.ifs
;
952 for ( i
= 0; i
< ifs
.size(); i
++ )
955 if ( rIf
.data
.defines
.size()
956 || rIf
.data
.includes
.size()
957 || rIf
.data
.libraries
.size()
958 || rIf
.data
.compilationUnits
.size()
959 || rIf
.data
.compilerFlags
.size()
960 || rIf
.data
.ifs
.size() )
964 "%s (\"$(%s)\",\"%s\")\n",
965 rIf
.negated
? "ifneq" : "ifeq",
966 rIf
.property
.c_str(),
968 GenerateSourceMacros (
977 vector
<CompilationUnit
*> sourceCompilationUnits
;
978 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
979 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
981 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
985 sourcesMacro
.c_str(),
986 backend
->GetFullName ( compilationName
).c_str () );
988 CleanupCompilationUnitVector ( sourceCompilationUnits
);
992 MingwModuleHandler::GenerateObjectMacros (
993 const char* assignmentOperation
,
994 const IfableData
& data
)
998 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
999 vector
<const FileLocation
*> headers
;
1000 vector
<const FileLocation
*> mcheaders
;
1001 vector
<const FileLocation
*> mcresources
;
1002 if ( compilationUnits
.size () > 0 )
1004 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1006 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1007 if ( compilationUnit
.IsFirstFile () )
1009 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1010 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1011 fprintf ( fMakefile
,
1013 objectsMacro
.c_str(),
1014 backend
->GetFullName ( *object_file
).c_str (),
1015 objectsMacro
.c_str() );
1022 objectsMacro
.c_str (),
1023 assignmentOperation
);
1024 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
1026 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1027 if ( !compilationUnit
.IsFirstFile () )
1029 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1030 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1031 if ( GetExtension ( *objectFilename
) == ".h" )
1032 headers
.push_back ( objectFilename
);
1033 else if ( GetExtension ( *objectFilename
) == ".rc" )
1035 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
1036 mcheaders
.push_back ( headerFilename
);
1037 mcresources
.push_back ( objectFilename
);
1044 ( i
%10 == 9 ? " \\\n\t" : " " ),
1045 backend
->GetFullName ( *objectFilename
).c_str () );
1046 delete objectFilename
;
1050 fprintf ( fMakefile
, "\n" );
1052 if ( headers
.size () > 0 )
1057 module
.name
.c_str (),
1058 assignmentOperation
);
1059 for ( i
= 0; i
< headers
.size (); i
++ )
1064 ( i
%10 == 9 ? " \\\n\t" : " " ),
1065 backend
->GetFullName ( *headers
[i
] ).c_str () );
1068 fprintf ( fMakefile
, "\n" );
1071 if ( mcheaders
.size () > 0 )
1076 module
.name
.c_str (),
1077 assignmentOperation
);
1078 for ( i
= 0; i
< mcheaders
.size (); i
++ )
1083 ( i
%10 == 9 ? " \\\n\t" : " " ),
1084 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
1085 delete mcheaders
[i
];
1087 fprintf ( fMakefile
, "\n" );
1090 if ( mcresources
.size () > 0 )
1095 module
.name
.c_str (),
1096 assignmentOperation
);
1097 for ( i
= 0; i
< mcresources
.size (); i
++ )
1102 ( i
%10 == 9 ? " \\\n\t" : " " ),
1103 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
1104 delete mcresources
[i
];
1106 fprintf ( fMakefile
, "\n" );
1109 const vector
<If
*>& ifs
= data
.ifs
;
1110 for ( i
= 0; i
< ifs
.size(); i
++ )
1113 if ( rIf
.data
.defines
.size()
1114 || rIf
.data
.includes
.size()
1115 || rIf
.data
.libraries
.size()
1116 || rIf
.data
.compilationUnits
.size()
1117 || rIf
.data
.compilerFlags
.size()
1118 || rIf
.data
.ifs
.size() )
1122 "%s (\"$(%s)\",\"%s\")\n",
1123 rIf
.negated
? "ifneq" : "ifeq",
1124 rIf
.property
.c_str(),
1125 rIf
.value
.c_str() );
1126 GenerateObjectMacros (
1135 vector
<CompilationUnit
*> sourceCompilationUnits
;
1136 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1137 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1139 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1140 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1144 objectsMacro
.c_str(),
1145 backend
->GetFullName ( *object_file
).c_str () );
1148 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1151 /* caller needs to delete the returned object */
1153 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1155 if ( !module
.pch
|| !use_pch
)
1157 return new FileLocation ( IntermediateDirectory
,
1158 module
.pch
->file
->relative_path
,
1159 module
.pch
->file
->name
+ ".gch" );
1162 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1163 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1164 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1165 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1166 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1168 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1169 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1171 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1172 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1174 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1175 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1176 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1177 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1178 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1180 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1181 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1182 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1183 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1185 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1186 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1187 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1188 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1189 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1191 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1192 "\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"
1193 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1194 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1195 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1196 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1197 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1198 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"
1200 "\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",
1201 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1202 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1203 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1204 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1205 "\t$(ECHO_WINEBLD)\n"
1206 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source)\n"
1207 "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1208 "\t$(ECHO_WINEBLD)\n"
1209 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c --pedll $(source_path)$(SEP)$(source_name_noext).spec\n"
1210 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1212 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1213 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1214 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1215 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1216 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1217 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1218 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1220 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1221 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1222 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1223 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1224 "$(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"
1226 "\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"
1227 "$(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"
1229 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1230 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1231 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1232 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1233 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1234 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1235 "$(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"
1237 "\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"
1238 "$(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"
1240 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1241 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1242 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1243 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1244 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1245 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1246 "$(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"
1248 "\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"
1249 "$(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"
1251 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1252 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1253 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1254 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1255 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1256 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1257 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1259 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1260 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1261 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1262 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1264 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1265 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1266 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1267 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1269 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1270 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1271 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1272 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1274 "\t${gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1275 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1276 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1277 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1279 "\t${host_gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1280 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1281 Rule
emptyRule ( "", NULL
);
1284 MingwModuleHandler::GenerateGccCommand (
1285 const FileLocation
* sourceFile
,
1287 const string
& extraDependencies
)
1289 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1290 string dependencies
= extraDependencies
;
1293 string extension
= GetExtension ( *sourceFile
);
1294 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1295 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1297 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1301 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1305 /* WIDL generated headers may be used */
1306 vector
<FileLocation
> rpcDependencies
;
1307 GetRpcHeaderDependencies ( rpcDependencies
);
1308 if ( rpcDependencies
.size () > 0 )
1309 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1311 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1315 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1317 for ( size_t i
= 0; i
< module
.project
.non_if_data
.properties
.size (); i
++ )
1319 const Property
& property
= *module
.project
.non_if_data
.properties
[i
];
1320 if ( property
.name
== name
)
1321 return property
.value
;
1323 return string ( "" );
1326 /* caller needs to delete the returned object */
1328 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1330 string newname
= GetBasename ( base
->name
) + "_s.h";
1331 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1334 /* caller needs to delete the returned object */
1336 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1338 string newname
= GetBasename ( base
->name
) + "_c.h";
1339 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1342 /* caller needs to delete the returned object */
1344 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1346 string newname
= GetBasename ( base
->name
) + "_p.h";
1347 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1350 /* caller needs to delete the returned object */
1352 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1354 string newname
= GetBasename ( base
->name
) + ".h";
1355 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1358 /* caller needs to delete the returned object */
1360 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1362 string newname
= GetBasename ( base
->name
) + ".h";
1363 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1367 MingwModuleHandler::GenerateCommands (
1368 const CompilationUnit
& compilationUnit
,
1369 const string
& extraDependencies
)
1371 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1372 string extension
= GetExtension ( sourceFile
);
1373 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1382 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1383 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1384 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1385 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1386 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1387 { HostDontCare
, TypeDontCare
, ".spec", &winebuildRule
},
1388 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1389 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1390 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1391 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1392 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1393 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1394 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1395 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1396 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1397 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1398 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1399 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1400 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1401 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1404 Rule
*customRule
= NULL
;
1406 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1408 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= module
.host
)
1410 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1412 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1414 customRule
= rules
[i
].rule
;
1418 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1420 GenerateGccCommand ( &sourceFile
,
1422 GetCompilationUnitDependencies ( compilationUnit
) + GetExtraDependencies ( &sourceFile
) + extraDependencies
);
1424 else if ( customRule
)
1425 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1428 throw InvalidOperationException ( __FILE__
,
1430 "Unsupported filename extension '%s' in file '%s'",
1432 backend
->GetFullName ( sourceFile
).c_str () );
1437 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1439 fprintf ( fMakefile
,
1440 "ifeq ($(ROS_BUILDMAP),full)\n" );
1442 FileLocation
mapFilename ( OutputDirectory
,
1443 module
.output
->relative_path
,
1444 GetBasename ( module
.output
->name
) + ".map" );
1445 CLEAN_FILE ( mapFilename
);
1447 fprintf ( fMakefile
,
1448 "\t$(ECHO_OBJDUMP)\n" );
1449 fprintf ( fMakefile
,
1450 "\t$(Q)${objdump} -d -S %s > %s\n",
1451 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1452 backend
->GetFullName ( mapFilename
).c_str () );
1454 fprintf ( fMakefile
,
1456 fprintf ( fMakefile
,
1457 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1459 fprintf ( fMakefile
,
1461 fprintf ( fMakefile
,
1462 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1463 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1464 backend
->GetFullName ( mapFilename
).c_str () );
1466 fprintf ( fMakefile
,
1469 fprintf ( fMakefile
,
1474 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1476 fprintf ( fMakefile
,
1477 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1479 FileLocation
nostripFilename ( OutputDirectory
,
1480 module
.output
->relative_path
,
1481 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1482 CLEAN_FILE ( nostripFilename
);
1484 OutputCopyCommand ( *module
.output
, nostripFilename
);
1486 fprintf ( fMakefile
,
1491 MergeStringVector ( const Backend
* backend
,
1492 const vector
<FileLocation
>& input
,
1493 vector
<string
>& output
)
1497 int wrap_count
= -1;
1498 for ( size_t i
= 0; i
< input
.size (); i
++ )
1500 if ( wrap_count
++ == wrap_at
)
1502 output
.push_back ( s
);
1506 else if ( s
.size () > 0)
1508 s
+= backend
->GetFullName ( input
[i
] );
1510 if ( s
.length () > 0 )
1511 output
.push_back ( s
);
1515 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1516 vector
<FileLocation
>& objectFiles
) const
1518 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1520 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1521 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1522 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1523 objectFiles
.push_back ( *object_file
);
1529 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1531 if ( backend
->configuration
.CleanAsYouGo
)
1533 vector
<FileLocation
> objectFiles
;
1534 GetObjectsVector ( module
.non_if_data
,
1536 vector
<string
> lines
;
1537 MergeStringVector ( backend
,
1540 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1542 fprintf ( fMakefile
,
1543 "\t-@${rm} %s 2>$(NUL)\n",
1544 lines
[i
].c_str () );
1550 MingwModuleHandler::GenerateRunRsymCode () const
1552 fprintf ( fMakefile
,
1553 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1554 fprintf ( fMakefile
,
1555 "\t$(ECHO_RSYM)\n" );
1556 fprintf ( fMakefile
,
1557 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1558 fprintf ( fMakefile
,
1563 MingwModuleHandler::GenerateRunStripCode () const
1565 fprintf ( fMakefile
,
1566 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1567 fprintf ( fMakefile
,
1568 "\t$(ECHO_STRIP)\n" );
1569 fprintf ( fMakefile
,
1570 "\t${strip} -s -x -X $@\n\n" );
1571 fprintf ( fMakefile
,
1576 MingwModuleHandler::GenerateLinkerCommand (
1577 const string
& dependencies
,
1578 const string
& linkerParameters
,
1579 const string
& pefixupParameters
)
1581 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1582 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1583 const FileLocation
temp_obj ( TemporaryDirectory
, "", module
.name
+ ".temp.ld" );
1584 string linker
= "${ld}";
1585 string objectsMacro
= GetObjectsMacro ( module
);
1586 string libsMacro
= GetLibsMacro ();
1588 string
target_macro ( GetTargetMacro ( module
) );
1589 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1591 string linkerScriptArgument
;
1592 if ( module
.linkerScript
!= NULL
)
1593 linkerScriptArgument
= ssprintf ( " -T=%s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1595 linkerScriptArgument
= "";
1597 fprintf ( fMakefile
,
1598 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1599 target_macro
.c_str (),
1600 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1601 dependencies
.c_str (),
1602 target_folder
.c_str () );
1603 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1604 string
targetName ( module
.output
->name
);
1606 fprintf ( fMakefile
, "\t@echo $(subst $(SEP),/,%s) > %s\n",
1607 objectsMacro
.c_str (),
1608 backend
->GetFullName ( temp_obj
).c_str () );
1609 CLEAN_FILE ( temp_obj
);
1611 if ( !module
.IsDLL () )
1613 fprintf ( fMakefile
,
1614 "\t%s %s%s @%s %s%s %s -o %s\n",
1616 linkerParameters
.c_str (),
1617 linkerScriptArgument
.c_str (),
1618 backend
->GetFullName ( temp_obj
).c_str (),
1619 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1621 GetLinkerMacro ().c_str (),
1622 target_macro
.c_str () );
1624 else if ( module
.HasImportLibrary () )
1626 FileLocation
temp_exp ( TemporaryDirectory
,
1628 module
.name
+ ".temp.exp" );
1629 CLEAN_FILE ( temp_exp
);
1631 fprintf ( fMakefile
,
1632 "\t${dlltool} --dllname %s --def %s --output-exp %s%s%s\n",
1633 targetName
.c_str (),
1634 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1635 backend
->GetFullName ( temp_exp
).c_str (),
1636 module
.mangledSymbols
? "" : " --kill-at",
1637 module
.underscoreSymbols
? " --add-underscore" : "" );
1639 fprintf ( fMakefile
,
1640 "\t%s %s%s %s @%s %s%s %s -o %s\n",
1642 linkerParameters
.c_str (),
1643 linkerScriptArgument
.c_str (),
1644 backend
->GetFullName ( temp_exp
).c_str (),
1645 backend
->GetFullName ( temp_obj
).c_str (),
1646 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1648 GetLinkerMacro ().c_str (),
1649 target_macro
.c_str () );
1651 fprintf ( fMakefile
,
1652 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1653 target_macro
.c_str (),
1654 pefixupParameters
.c_str() );
1656 fprintf ( fMakefile
,
1657 "\t-@${rm} %s 2>$(NUL)\n",
1658 backend
->GetFullName ( temp_exp
).c_str () );
1662 /* XXX: need to workaround binutils bug, which exports
1663 * all functions in a dll if no .def file or an empty
1664 * one has been provided... */
1666 //printf ( "%s will have all its functions exported\n",
1667 // module.target->name.c_str () );
1668 fprintf ( fMakefile
,
1669 "\t%s %s%s @%s %s%s %s -o %s\n",
1671 linkerParameters
.c_str (),
1672 linkerScriptArgument
.c_str (),
1673 backend
->GetFullName ( temp_obj
).c_str (),
1674 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1676 GetLinkerMacro ().c_str (),
1677 target_macro
.c_str () );
1680 GenerateBuildMapCode ();
1681 GenerateBuildNonSymbolStrippedCode ();
1682 GenerateRunRsymCode ();
1683 GenerateRunStripCode ();
1684 GenerateCleanObjectsAsYouGoCode ();
1686 if ( definitionFilename
)
1687 delete definitionFilename
;
1692 MingwModuleHandler::GeneratePhonyTarget() const
1694 string
targetMacro ( GetTargetMacro ( module
) );
1695 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1697 fprintf ( fMakefile
,
1699 targetMacro
.c_str ());
1700 fprintf ( fMakefile
, "%s: | %s\n",
1701 targetMacro
.c_str (),
1702 backend
->GetFullPath ( *target_file
).c_str () );
1708 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1711 string moduleDependencies
;
1713 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1714 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1716 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1717 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1718 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1719 if ( GetExtension ( *objectFilename
) == ".h" )
1720 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1721 else if ( GetExtension ( *objectFilename
) == ".rc" )
1722 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1723 delete objectFilename
;
1726 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1728 GenerateCommands ( *compilationUnits
[i
],
1729 moduleDependencies
);
1730 fprintf ( fMakefile
,
1734 const vector
<If
*>& ifs
= data
.ifs
;
1735 for ( i
= 0; i
< ifs
.size(); i
++ )
1737 GenerateObjectFileTargets ( ifs
[i
]->data
);
1740 vector
<CompilationUnit
*> sourceCompilationUnits
;
1741 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1742 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1744 GenerateCommands ( *sourceCompilationUnits
[i
],
1745 moduleDependencies
);
1747 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1751 MingwModuleHandler::GenerateObjectFileTargets ()
1753 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1757 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1758 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1760 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1761 CLEAN_FILE ( *pchFilename
);
1762 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1763 /* WIDL generated headers may be used */
1764 vector
<FileLocation
> rpcDependencies
;
1765 GetRpcHeaderDependencies ( rpcDependencies
);
1766 if ( rpcDependencies
.size () > 0 )
1767 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1768 fprintf ( fMakefile
,
1770 backend
->GetFullName ( *pchFilename
).c_str(),
1771 dependencies
.c_str(),
1772 backend
->GetFullPath ( *pchFilename
).c_str() );
1773 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1774 fprintf ( fMakefile
,
1775 "\t%s -o %s %s -g %s\n\n",
1776 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1777 backend
->GetFullName ( *pchFilename
).c_str(),
1778 cflagsMacro
.c_str(),
1779 backend
->GetFullName ( baseHeaderFile
).c_str() );
1783 GenerateObjectFileTargets ( module
.non_if_data
);
1784 fprintf ( fMakefile
, "\n" );
1787 /* caller needs to delete the returned object */
1789 MingwModuleHandler::GenerateArchiveTarget ()
1791 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1792 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1794 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1796 if ( IsStaticLibrary ( module
) && definitionFilename
)
1798 fprintf ( fMakefile
,
1799 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1800 module
.importLibrary
->dllname
.c_str (),
1801 backend
->GetFullName ( *definitionFilename
).c_str (),
1802 module
.mangledSymbols
? "" : " --kill-at",
1803 module
.underscoreSymbols
? " --add-underscore" : "" );
1806 if ( definitionFilename
)
1807 delete definitionFilename
;
1809 if(module
.type
== HostStaticLibrary
)
1810 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1812 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1814 GenerateCleanObjectsAsYouGoCode ();
1816 fprintf ( fMakefile
, "\n" );
1818 return archiveFilename
;
1822 MingwModuleHandler::GetCFlagsMacro () const
1824 return ssprintf ( "$(%s_CFLAGS)",
1825 module
.name
.c_str () );
1829 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1831 return ssprintf ( "$(%s_OBJS)",
1832 module
.name
.c_str () );
1836 MingwModuleHandler::GetLinkingDependenciesMacro () const
1838 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1842 MingwModuleHandler::GetLibsMacro () const
1844 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1848 MingwModuleHandler::GetLinkerMacro () const
1850 return ssprintf ( "$(%s_LFLAGS)",
1851 module
.name
.c_str () );
1855 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1857 if ( ReferenceObjects ( module
) )
1858 return GetObjectsMacro ( module
);
1861 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1862 string target
= backend
->GetFullName ( *target_file
).c_str ();
1869 MingwModuleHandler::GenerateSourceMacro ()
1871 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1873 GenerateSourceMacros (
1875 module
.non_if_data
);
1877 // future references to the macro will be to get its values
1878 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1882 MingwModuleHandler::GenerateObjectMacro ()
1884 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1886 GenerateObjectMacros (
1888 module
.non_if_data
);
1890 // future references to the macro will be to get its values
1891 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1895 MingwModuleHandler::GenerateTargetMacro ()
1897 fprintf ( fMakefile
,
1899 GetTargetMacro ( module
, false ).c_str (),
1900 GetModuleTargets ( module
).c_str () );
1904 MingwModuleHandler::GetRpcHeaderDependencies (
1905 vector
<FileLocation
>& dependencies
) const
1907 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1909 Library
& library
= *module
.non_if_data
.libraries
[i
];
1910 if ( library
.importedModule
->type
== RpcServer
||
1911 library
.importedModule
->type
== RpcClient
||
1912 library
.importedModule
->type
== RpcProxy
||
1913 library
.importedModule
->type
== IdlHeader
)
1915 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1917 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1918 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1919 string extension
= GetExtension ( sourceFile
);
1920 if ( extension
== ".idl" || extension
== ".IDL" )
1922 string basename
= GetBasename ( sourceFile
.name
);
1923 if ( library
.importedModule
->type
== RpcServer
)
1925 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1926 dependencies
.push_back ( *header
);
1929 if ( library
.importedModule
->type
== RpcClient
)
1931 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1932 dependencies
.push_back ( *header
);
1935 if ( library
.importedModule
->type
== RpcProxy
)
1937 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1938 dependencies
.push_back ( *header
);
1941 if ( library
.importedModule
->type
== IdlHeader
)
1943 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1944 dependencies
.push_back ( *header
);
1954 MingwModuleHandler::GenerateOtherMacros ()
1956 set
<const Define
*> used_defs
;
1958 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1959 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1960 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1961 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1962 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1963 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1964 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1969 &module
.linkerFlags
,
1972 if ( module
.host
== HostFalse
)
1976 module
.project
.non_if_data
,
1981 vector
<FileLocation
> s
;
1982 if ( module
.importLibrary
)
1984 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
1985 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
1987 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1988 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1989 string extension
= GetExtension ( sourceFile
);
1990 if ( extension
== ".spec" || extension
== ".SPEC" )
1991 GetSpecObjectDependencies ( s
, &sourceFile
);
1994 if ( s
.size () > 0 )
1999 linkDepsMacro
.c_str() );
2000 for ( size_t i
= 0; i
< s
.size(); i
++ )
2001 fprintf ( fMakefile
,
2003 backend
->GetFullName ( s
[i
] ).c_str () );
2004 fprintf ( fMakefile
, "\n" );
2007 string globalCflags
= "";
2008 if ( module
.host
== HostFalse
)
2009 globalCflags
+= " $(PROJECT_CFLAGS)";
2011 globalCflags
+= " -Wall -Wpointer-arith -D__REACTOS__";
2012 globalCflags
+= " -g";
2013 if ( backend
->usePipe
)
2014 globalCflags
+= " -pipe";
2015 if ( !module
.allowWarnings
)
2016 globalCflags
+= " -Werror";
2017 if ( module
.host
== HostTrue
)
2019 if ( module
.cplusplus
)
2020 globalCflags
+= " $(HOST_CPPFLAGS)";
2022 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
2026 if ( module
.cplusplus
)
2028 // HACK: use host headers when building C++
2029 globalCflags
+= " $(HOST_CPPFLAGS)";
2032 globalCflags
+= " -nostdinc";
2035 // Always force disabling of sibling calls optimisation for GCC
2036 // (TODO: Move to version-specific once this bug is fixed in GCC)
2037 globalCflags
+= " -fno-optimize-sibling-calls";
2042 cflagsMacro
.c_str (),
2043 globalCflags
.c_str () );
2045 if ( module
.host
== HostFalse
)
2049 "%s += $(PROJECT_RCFLAGS)\n",
2050 windresflagsMacro
.c_str () );
2054 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
2055 widlflagsMacro
.c_str (),
2056 module
.output
->relative_path
.c_str () );
2060 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
2061 module
.name
.c_str () );
2067 "%s_LFLAGS += $(HOST_LFLAGS)\n",
2068 module
.name
.c_str () );
2074 linkDepsMacro
.c_str (),
2075 libsMacro
.c_str () );
2077 string cflags
= TypeSpecificCFlags();
2078 if ( cflags
.size() > 0 )
2080 fprintf ( fMakefile
,
2082 cflagsMacro
.c_str (),
2086 string nasmflags
= TypeSpecificNasmFlags();
2087 if ( nasmflags
.size () > 0 )
2089 fprintf ( fMakefile
,
2091 nasmflagsMacro
.c_str (),
2092 nasmflags
.c_str () );
2095 string linkerflags
= TypeSpecificLinkerFlags();
2096 if ( linkerflags
.size() > 0 )
2098 fprintf ( fMakefile
,
2100 linkerflagsMacro
.c_str (),
2101 linkerflags
.c_str () );
2104 if ( IsStaticLibrary ( module
) && module
.isStartupLib
)
2106 fprintf ( fMakefile
,
2107 "%s += -Wno-main\n\n",
2108 cflagsMacro
.c_str () );
2111 fprintf ( fMakefile
, "\n\n" );
2113 // future references to the macros will be to get their values
2114 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2115 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2116 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2120 MingwModuleHandler::GenerateRules ()
2122 string targetMacro
= GetTargetMacro ( module
);
2123 //CLEAN_FILE ( targetMacro );
2124 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2126 // generate phony target for module name
2127 fprintf ( fMakefile
, ".PHONY: %s\n",
2128 module
.name
.c_str () );
2129 string dependencies
= GetTargetMacro ( module
);
2130 if ( module
.type
== Test
)
2131 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2132 fprintf ( fMakefile
, "%s: %s\n\n",
2133 module
.name
.c_str (),
2134 dependencies
.c_str () );
2135 if ( module
.type
== Test
)
2137 fprintf ( fMakefile
,
2139 targetMacro
.c_str ());
2142 if ( !ReferenceObjects ( module
) )
2144 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2148 GenerateObjectFileTargets ();
2152 MingwModuleHandler::GetInvocationDependencies (
2153 const Module
& module
,
2154 string_list
& dependencies
)
2156 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2158 Invoke
& invoke
= *module
.invocations
[i
];
2159 if ( invoke
.invokeModule
== &module
)
2160 /* Protect against circular dependencies */
2162 invoke
.GetTargets ( dependencies
);
2167 MingwModuleHandler::GenerateInvocations () const
2169 if ( module
.invocations
.size () == 0 )
2172 size_t iend
= module
.invocations
.size ();
2173 for ( size_t i
= 0; i
< iend
; i
++ )
2175 const Invoke
& invoke
= *module
.invocations
[i
];
2177 if ( invoke
.invokeModule
->type
!= BuildTool
)
2179 throw XMLInvalidBuildFileException (
2180 module
.node
.location
,
2181 "Only modules of type buildtool can be invoked." );
2184 string invokeTarget
= module
.GetInvocationTarget ( i
);
2185 string_list invoke_targets
;
2186 assert ( invoke_targets
.size() );
2187 invoke
.GetTargets ( invoke_targets
);
2188 fprintf ( fMakefile
,
2190 invokeTarget
.c_str () );
2191 fprintf ( fMakefile
,
2193 invokeTarget
.c_str () );
2194 size_t j
, jend
= invoke_targets
.size();
2195 for ( j
= 0; j
< jend
; j
++ )
2197 fprintf ( fMakefile
,
2199 invoke_targets
[i
].c_str () );
2201 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2202 for ( j
= 1; j
< jend
; j
++ )
2203 fprintf ( fMakefile
,
2205 invoke_targets
[i
].c_str () );
2206 fprintf ( fMakefile
,
2208 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2209 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2210 fprintf ( fMakefile
,
2212 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2213 invoke
.GetParameters ().c_str () );
2218 MingwModuleHandler::GetPreconditionDependenciesName () const
2220 return module
.name
+ "_precondition";
2224 MingwModuleHandler::GetDefaultDependencies (
2225 string_list
& dependencies
) const
2227 /* Avoid circular dependency */
2228 if ( module
.host
== HostTrue
)
2231 if (module
.name
!= "psdk" &&
2232 module
.name
!= "dxsdk")
2234 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2235 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2238 if (module
.name
!= "errcodes" &&
2239 module
.name
!= "bugcodes" &&
2240 module
.name
!= "ntstatus")
2242 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2243 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2244 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2247 ///* Check if any dependent library relies on the generated headers */
2248 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2250 // const Module& m = *module.project.modules[i];
2251 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2253 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2254 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2255 // string extension = GetExtension ( sourceFile );
2256 // if (extension == ".mc" || extension == ".MC" )
2258 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2259 // dependencies.push_back ( dependency );
2266 MingwModuleHandler::GeneratePreconditionDependencies ()
2268 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2269 string_list dependencies
;
2270 GetDefaultDependencies ( dependencies
);
2271 GetModuleDependencies ( dependencies
);
2273 GetInvocationDependencies ( module
, dependencies
);
2275 if ( dependencies
.size() )
2277 fprintf ( fMakefile
,
2279 preconditionDependenciesName
.c_str () );
2280 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2281 fprintf ( fMakefile
,
2283 dependencies
[i
].c_str () );
2284 fprintf ( fMakefile
, "\n\n" );
2287 fprintf ( fMakefile
, "\n" );
2291 MingwModuleHandler::IsWineModule () const
2293 if ( module
.importLibrary
== NULL
)
2296 size_t index
= module
.importLibrary
->source
->name
.rfind ( ".spec.def" );
2297 return ( index
!= string::npos
);
2300 /* caller needs to delete the returned object */
2302 MingwModuleHandler::GetDefinitionFilename () const
2304 if ( module
.importLibrary
== NULL
)
2307 DirectoryLocation directory
;
2308 if ( IsWineModule () )
2309 directory
= IntermediateDirectory
;
2311 directory
= SourceDirectory
;
2313 return new FileLocation ( directory
,
2314 module
.importLibrary
->source
->relative_path
,
2315 module
.importLibrary
->source
->name
);
2319 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2321 if ( module
.importLibrary
!= NULL
)
2323 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2324 const FileLocation
*defFilename
= GetDefinitionFilename ();
2325 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2327 vector
<FileLocation
> deps
;
2328 GetDefinitionDependencies ( deps
);
2330 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
2332 fprintf ( fMakefile
, "%s:",
2333 backend
->GetFullName ( *library_target
).c_str () );
2337 fprintf ( fMakefile
, " %s",
2338 backend
->GetFullName ( *defFilename
).c_str () );
2341 size_t i
, iend
= deps
.size();
2342 for ( i
= 0; i
< iend
; i
++ )
2343 fprintf ( fMakefile
, " %s",
2344 backend
->GetFullName ( deps
[i
] ).c_str () );
2346 fprintf ( fMakefile
, " | %s\n",
2347 backend
->GetFullPath ( *library_target
).c_str () );
2349 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2351 fprintf ( fMakefile
,
2352 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2353 module
.output
->name
.c_str (),
2354 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2356 backend
->GetFullName ( *library_target
).c_str (),
2357 module
.mangledSymbols
? "" : " --kill-at",
2358 module
.underscoreSymbols
? " --add-underscore" : "" );
2362 delete library_target
;
2367 MingwModuleHandler::GetSpecObjectDependencies (
2368 vector
<FileLocation
>& dependencies
,
2369 const FileLocation
*file
) const
2371 string basename
= GetBasename ( file
->name
);
2373 FileLocation
defDependency ( IntermediateDirectory
,
2374 file
->relative_path
,
2375 basename
+ ".spec.def" );
2376 dependencies
.push_back ( defDependency
);
2378 FileLocation
stubsDependency ( IntermediateDirectory
,
2379 file
->relative_path
,
2380 basename
+ ".stubs.c" );
2381 dependencies
.push_back ( stubsDependency
);
2385 MingwModuleHandler::GetMcObjectDependencies (
2386 vector
<FileLocation
>& dependencies
,
2387 const FileLocation
*file
) const
2389 string basename
= GetBasename ( file
->name
);
2391 FileLocation
defDependency ( IntermediateDirectory
,
2394 dependencies
.push_back ( defDependency
);
2396 FileLocation
stubsDependency ( IntermediateDirectory
,
2397 file
->relative_path
,
2399 dependencies
.push_back ( stubsDependency
);
2403 MingwModuleHandler::GetWidlObjectDependencies (
2404 vector
<FileLocation
>& dependencies
,
2405 const FileLocation
*file
) const
2407 string basename
= GetBasename ( file
->name
);
2408 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2410 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2411 file
->relative_path
,
2412 basename
+ "_s.c" );
2413 dependencies
.push_back ( serverSourceDependency
);
2414 dependencies
.push_back ( *generatedHeaderFilename
);
2416 delete generatedHeaderFilename
;
2420 MingwModuleHandler::GetDefinitionDependencies (
2421 vector
<FileLocation
>& dependencies
) const
2423 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2424 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2426 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2427 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2428 string extension
= GetExtension ( sourceFile
);
2429 if ( extension
== ".spec" || extension
== ".SPEC" )
2430 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2431 if ( extension
== ".idl" || extension
== ".IDL" )
2433 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2434 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2439 enum DebugSupportType
2446 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2452 case DebugKernelMode
:
2453 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2457 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2464 module
.non_if_data
.libraries
.push_back(pLibrary
);
2467 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2468 : MingwModuleHandler ( module_
)
2473 MingwBuildToolModuleHandler::Process ()
2475 GenerateBuildToolModuleTarget ();
2479 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2481 string
targetMacro ( GetTargetMacro (module
) );
2482 string objectsMacro
= GetObjectsMacro ( module
);
2483 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2484 string libsMacro
= GetLibsMacro ();
2489 if ( module
.cplusplus
)
2490 linker
= "${host_gpp}";
2492 linker
= "${host_gcc}";
2494 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2495 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2496 targetMacro
.c_str (),
2497 objectsMacro
.c_str (),
2498 linkDepsMacro
.c_str (),
2499 backend
->GetFullPath ( *target_file
).c_str () );
2500 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2501 fprintf ( fMakefile
,
2502 "\t%s %s -o $@ %s %s\n\n",
2504 GetLinkerMacro ().c_str (),
2505 objectsMacro
.c_str (),
2506 libsMacro
.c_str () );
2512 MingwKernelModuleHandler::MingwKernelModuleHandler (
2513 const Module
& module_
)
2515 : MingwModuleHandler ( module_
)
2520 MingwKernelModuleHandler::Process ()
2522 GenerateKernelModuleTarget ();
2526 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2528 string
targetMacro ( GetTargetMacro ( module
) );
2529 string workingDirectory
= GetWorkingDirectory ( );
2530 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2532 GenerateImportLibraryTargetIfNeeded ();
2534 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2538 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2540 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2541 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2542 module
.baseaddress
.c_str () );
2544 GenerateLinkerCommand ( dependencies
,
2545 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2550 GeneratePhonyTarget();
2555 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2556 const Module
& module_
)
2558 : MingwModuleHandler ( module_
)
2563 MingwStaticLibraryModuleHandler::Process ()
2565 GenerateStaticLibraryModuleTarget ();
2569 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2575 MingwHostStaticLibraryModuleHandler::MingwHostStaticLibraryModuleHandler (
2576 const Module
& module_
)
2578 : MingwModuleHandler ( module_
)
2583 MingwHostStaticLibraryModuleHandler::Process ()
2585 GenerateHostStaticLibraryModuleTarget ();
2589 MingwHostStaticLibraryModuleHandler::GenerateHostStaticLibraryModuleTarget ()
2595 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2596 const Module
& module_
)
2598 : MingwModuleHandler ( module_
)
2603 MingwObjectLibraryModuleHandler::Process ()
2605 GenerateObjectLibraryModuleTarget ();
2609 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2615 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2616 const Module
& module_
)
2618 : MingwModuleHandler ( module_
)
2622 MingwEmbeddedTypeLibModuleHandler::MingwEmbeddedTypeLibModuleHandler (
2623 const Module
& module_
)
2625 : MingwModuleHandler ( module_
)
2630 MingwEmbeddedTypeLibModuleHandler::Process ()
2637 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2639 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2643 MingwKernelModeDLLModuleHandler::Process ()
2645 GenerateKernelModeDLLModuleTarget ();
2649 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2651 string
targetMacro ( GetTargetMacro ( module
) );
2652 string workingDirectory
= GetWorkingDirectory ( );
2653 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2655 GenerateImportLibraryTargetIfNeeded ();
2657 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2661 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2663 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2664 module
.GetEntryPoint(true).c_str (),
2665 module
.baseaddress
.c_str () );
2666 GenerateLinkerCommand ( dependencies
,
2672 GeneratePhonyTarget();
2677 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2678 const Module
& module_
)
2680 : MingwModuleHandler ( module_
)
2685 MingwKernelModeDriverModuleHandler::AddImplicitLibraries ( Module
& module
)
2687 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2691 MingwKernelModeDriverModuleHandler::Process ()
2693 GenerateKernelModeDriverModuleTarget ();
2698 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2700 string
targetMacro ( GetTargetMacro (module
) );
2701 string workingDirectory
= GetWorkingDirectory ();
2702 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2704 GenerateImportLibraryTargetIfNeeded ();
2706 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2710 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2712 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2713 module
.GetEntryPoint(true).c_str (),
2714 module
.baseaddress
.c_str () );
2715 GenerateLinkerCommand ( dependencies
,
2721 GeneratePhonyTarget();
2726 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2727 const Module
& module_
)
2729 : MingwModuleHandler ( module_
)
2734 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2736 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2740 MingwNativeDLLModuleHandler::Process ()
2742 GenerateNativeDLLModuleTarget ();
2746 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2748 string
targetMacro ( GetTargetMacro (module
) );
2749 string workingDirectory
= GetWorkingDirectory ( );
2750 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2752 GenerateImportLibraryTargetIfNeeded ();
2754 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2758 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2760 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2761 module
.GetEntryPoint(true).c_str (),
2762 module
.baseaddress
.c_str () );
2763 GenerateLinkerCommand ( dependencies
,
2769 GeneratePhonyTarget();
2774 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2775 const Module
& module_
)
2777 : MingwModuleHandler ( module_
)
2782 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2784 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2788 MingwNativeCUIModuleHandler::Process ()
2790 GenerateNativeCUIModuleTarget ();
2794 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2796 string
targetMacro ( GetTargetMacro (module
) );
2797 string workingDirectory
= GetWorkingDirectory ( );
2798 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2800 GenerateImportLibraryTargetIfNeeded ();
2802 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2806 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2808 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2809 module
.GetEntryPoint(true).c_str (),
2810 module
.baseaddress
.c_str () );
2811 GenerateLinkerCommand ( dependencies
,
2817 GeneratePhonyTarget();
2822 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2823 const Module
& module_
)
2825 : MingwModuleHandler ( module_
)
2829 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2830 const Module
& module_
)
2832 : MingwModuleHandler ( module_
)
2837 LinksToCrt( Module
&module
)
2839 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
2841 Library
& library
= *module
.non_if_data
.libraries
[i
];
2842 if ( library
.name
== "libcntpr" || library
.name
== "crt" )
2849 MingwAddImplicitLibraries( Module
&module
)
2854 if ( module
.type
!= Win32DLL
2855 && module
.type
!= Win32OCX
2856 && module
.type
!= Win32CUI
2857 && module
.type
!= Win32GUI
2858 && module
.type
!= Win32SCR
)
2860 // no implicit libraries
2864 links_to_crt
= LinksToCrt ( module
);
2866 if ( !module
.isDefaultEntryPoint
)
2868 if ( module
.GetEntryPoint(false) == "0" )
2870 if ( !links_to_crt
)
2872 pLibrary
= new Library ( module
, "mingw_common" );
2873 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() , pLibrary
);
2875 pLibrary
= new Library ( module
, "msvcrt" );
2876 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2877 links_to_crt
= true;
2883 if ( module
.IsDLL () )
2885 //pLibrary = new Library ( module, "__mingw_dllmain" );
2886 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2890 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2891 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2894 pLibrary
= new Library ( module
, "mingw_common" );
2895 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() + 1, pLibrary
);
2897 if ( !links_to_crt
)
2899 // always link in msvcrt to get the basic routines
2900 pLibrary
= new Library ( module
, "msvcrt" );
2901 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2906 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2908 MingwAddImplicitLibraries ( module
);
2909 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2913 MingwWin32DLLModuleHandler::Process ()
2915 GenerateWin32DLLModuleTarget ();
2919 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2921 string
targetMacro ( GetTargetMacro (module
) );
2922 string workingDirectory
= GetWorkingDirectory ( );
2923 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2925 GenerateImportLibraryTargetIfNeeded ();
2927 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2931 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2933 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2934 module
.GetEntryPoint(true).c_str (),
2935 module
.baseaddress
.c_str () );
2936 GenerateLinkerCommand ( dependencies
,
2942 GeneratePhonyTarget();
2948 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2950 MingwAddImplicitLibraries ( module
);
2951 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2955 MingwWin32OCXModuleHandler::Process ()
2957 GenerateWin32OCXModuleTarget ();
2961 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2963 string
targetMacro ( GetTargetMacro (module
) );
2964 string workingDirectory
= GetWorkingDirectory ( );
2965 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2967 GenerateImportLibraryTargetIfNeeded ();
2969 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2973 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2975 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2976 module
.GetEntryPoint(true).c_str (),
2977 module
.baseaddress
.c_str () );
2978 GenerateLinkerCommand ( dependencies
,
2984 GeneratePhonyTarget();
2989 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2990 const Module
& module_
)
2992 : MingwModuleHandler ( module_
)
2997 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2999 MingwAddImplicitLibraries ( module
);
3000 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3004 MingwWin32CUIModuleHandler::Process ()
3006 GenerateWin32CUIModuleTarget ();
3010 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
3012 string
targetMacro ( GetTargetMacro (module
) );
3013 string workingDirectory
= GetWorkingDirectory ( );
3014 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3016 GenerateImportLibraryTargetIfNeeded ();
3018 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3022 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3024 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3025 module
.GetEntryPoint(true).c_str (),
3026 module
.baseaddress
.c_str () );
3027 GenerateLinkerCommand ( dependencies
,
3033 GeneratePhonyTarget();
3038 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
3039 const Module
& module_
)
3041 : MingwModuleHandler ( module_
)
3046 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3048 MingwAddImplicitLibraries ( module
);
3049 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3053 MingwWin32GUIModuleHandler::Process ()
3055 GenerateWin32GUIModuleTarget ();
3059 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
3061 string
targetMacro ( GetTargetMacro (module
) );
3062 string workingDirectory
= GetWorkingDirectory ( );
3063 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3065 GenerateImportLibraryTargetIfNeeded ();
3067 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3071 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3073 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3074 module
.GetEntryPoint(true).c_str (),
3075 module
.baseaddress
.c_str () );
3076 GenerateLinkerCommand ( dependencies
,
3082 GeneratePhonyTarget();
3087 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
3088 const Module
& module_
)
3090 : MingwModuleHandler ( module_
)
3095 MingwBootLoaderModuleHandler::Process ()
3097 GenerateBootLoaderModuleTarget ();
3101 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
3103 string
targetName ( module
.output
->name
);
3104 string
targetMacro ( GetTargetMacro (module
) );
3105 string workingDirectory
= GetWorkingDirectory ();
3106 FileLocation
junk_tmp ( TemporaryDirectory
,
3108 module
.name
+ ".junk.tmp" );
3109 CLEAN_FILE ( junk_tmp
);
3110 string objectsMacro
= GetObjectsMacro ( module
);
3111 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3112 string libsMacro
= GetLibsMacro ();
3116 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3117 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3118 targetMacro
.c_str (),
3119 objectsMacro
.c_str (),
3120 linkDepsMacro
.c_str (),
3121 backend
->GetFullPath ( *target_file
).c_str () );
3123 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
3125 if (Environment::GetArch() == "arm")
3127 fprintf ( fMakefile
,
3128 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
3129 backend
->GetFullName ( junk_tmp
).c_str (),
3130 objectsMacro
.c_str (),
3131 linkDepsMacro
.c_str (),
3132 GetLinkerMacro ().c_str ());
3136 fprintf ( fMakefile
,
3137 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
3138 backend
->GetFullName ( junk_tmp
).c_str (),
3139 objectsMacro
.c_str (),
3140 linkDepsMacro
.c_str (),
3141 GetLinkerMacro ().c_str ());
3143 fprintf ( fMakefile
,
3144 "\t${objcopy} -O binary %s $@\n",
3145 backend
->GetFullName ( junk_tmp
).c_str () );
3146 GenerateBuildMapCode ( &junk_tmp
);
3147 fprintf ( fMakefile
,
3148 "\t-@${rm} %s 2>$(NUL)\n",
3149 backend
->GetFullName ( junk_tmp
).c_str () );
3155 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
3156 const Module
& module_
)
3158 : MingwModuleHandler ( module_
)
3163 MingwBootSectorModuleHandler::Process ()
3165 GenerateBootSectorModuleTarget ();
3169 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
3171 string objectsMacro
= GetObjectsMacro ( module
);
3175 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3176 module
.name
.c_str ());
3177 fprintf ( fMakefile
,
3179 module
.name
.c_str (),
3180 objectsMacro
.c_str () );
3184 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
3185 const Module
& module_
)
3186 : MingwModuleHandler ( module_
)
3191 MingwBootProgramModuleHandler::Process ()
3193 GenerateBootProgramModuleTarget ();
3197 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3199 string
targetName ( module
.output
->name
);
3200 string
targetMacro ( GetTargetMacro (module
) );
3201 string workingDirectory
= GetWorkingDirectory ();
3202 FileLocation
junk_tmp ( TemporaryDirectory
,
3204 module
.name
+ ".junk.tmp" );
3205 FileLocation
junk_elf ( TemporaryDirectory
,
3207 module
.name
+ ".junk.elf" );
3208 FileLocation
junk_cpy ( TemporaryDirectory
,
3210 module
.name
+ ".junk.elf" );
3211 CLEAN_FILE ( junk_tmp
);
3212 CLEAN_FILE ( junk_elf
);
3213 CLEAN_FILE ( junk_cpy
);
3214 string objectsMacro
= GetObjectsMacro ( module
);
3215 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3216 string libsMacro
= GetLibsMacro ();
3217 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3221 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3222 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3223 targetMacro
.c_str (),
3224 objectsMacro
.c_str (),
3225 linkDepsMacro
.c_str (),
3226 payload
->name
.c_str (),
3227 backend
->GetFullPath ( *target_file
).c_str () );
3229 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3231 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3232 module
.buildtype
.c_str (),
3233 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3234 backend
->GetFullName ( junk_cpy
).c_str () );
3236 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3237 module
.buildtype
.c_str (),
3238 backend
->GetFullName ( junk_cpy
).c_str (),
3239 backend
->GetFullName ( junk_tmp
).c_str () );
3241 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3242 module
.buildtype
.c_str (),
3243 linkDepsMacro
.c_str (),
3244 backend
->GetFullName ( junk_tmp
).c_str (),
3245 backend
->GetFullName ( junk_elf
).c_str () );
3247 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3248 module
.buildtype
.c_str (),
3249 backend
->GetFullName ( junk_elf
).c_str (),
3250 backend
->GetFullName ( *module
.output
) .c_str () );
3252 fprintf ( fMakefile
,
3253 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3254 backend
->GetFullName ( junk_tmp
).c_str (),
3255 backend
->GetFullName ( junk_elf
).c_str (),
3256 backend
->GetFullName ( junk_cpy
).c_str () );
3262 MingwIsoModuleHandler::MingwIsoModuleHandler (
3263 const Module
& module_
)
3265 : MingwModuleHandler ( module_
)
3270 MingwIsoModuleHandler::Process ()
3272 GenerateIsoModuleTarget ();
3276 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3277 const string
& bootcdDirectory
)
3279 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3281 const Module
& m
= *module
.project
.modules
[i
];
3284 if ( m
.bootstrap
!= NULL
)
3286 FileLocation
targetFile ( OutputDirectory
,
3287 m
.bootstrap
->base
.length () > 0
3288 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3290 m
.bootstrap
->nameoncd
);
3291 OutputCopyCommand ( *m
.output
, targetFile
);
3297 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3298 const string
& bootcdDirectory
)
3300 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3302 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3303 FileLocation
targetFile ( OutputDirectory
,
3304 cdfile
.target
->relative_path
.length () > 0
3305 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3307 cdfile
.target
->name
);
3308 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3313 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3314 const string
& bootcdDirectory
)
3316 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3318 const Module
& m
= *module
.project
.modules
[i
];
3321 if ( m
.bootstrap
!= NULL
)
3323 FileLocation
targetDirectory ( OutputDirectory
,
3324 m
.bootstrap
->base
.length () > 0
3325 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3328 out
.push_back ( targetDirectory
);
3334 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3335 const string
& bootcdDirectory
)
3337 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3339 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3340 FileLocation
targetDirectory ( OutputDirectory
,
3341 cdfile
.target
->relative_path
.length () > 0
3342 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3345 out
.push_back( targetDirectory
);
3350 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3351 const string
& bootcdDirectory
)
3353 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3354 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3358 MingwIsoModuleHandler::GetBootstrapCdFiles (
3359 vector
<FileLocation
>& out
) const
3361 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3363 const Module
& m
= *module
.project
.modules
[i
];
3366 if ( m
.bootstrap
!= NULL
)
3368 out
.push_back ( *m
.output
);
3374 MingwIsoModuleHandler::GetNonModuleCdFiles (
3375 vector
<FileLocation
>& out
) const
3377 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3379 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3380 out
.push_back ( *cdfile
.source
);
3385 MingwIsoModuleHandler::GetCdFiles (
3386 vector
<FileLocation
>& out
) const
3388 GetBootstrapCdFiles ( out
);
3389 GetNonModuleCdFiles ( out
);
3393 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3395 string bootcdDirectory
= "cd";
3396 FileLocation
bootcd ( OutputDirectory
,
3399 FileLocation
bootcdReactos ( OutputDirectory
,
3400 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3402 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3403 vector
<FileLocation
> vCdDirectories
;
3406 FileLocation
srcunattend ( SourceDirectory
,
3407 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3409 FileLocation
tarunattend ( bootcdReactos
.directory
,
3410 bootcdReactos
.relative_path
,
3412 if (module
.type
== IsoRegTest
)
3413 vSourceFiles
.push_back ( srcunattend
);
3416 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3420 throw InvalidOperationException ( module
.node
.location
.c_str(),
3422 "Invalid bootsector. module '%s' requires <bootsector>",
3423 module
.name
.c_str ());
3426 const FileLocation
*isoboot
= bootModule
->output
;
3427 vSourceFiles
.push_back ( *isoboot
);
3429 // prepare reactos.dff and reactos.inf
3430 FileLocation
reactosDff ( SourceDirectory
,
3431 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3433 FileLocation
reactosInf ( bootcdReactos
.directory
,
3434 bootcdReactos
.relative_path
,
3437 vSourceFiles
.push_back ( reactosDff
);
3440 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3441 Iso/LiveIso outputs are generated in code base root
3443 string IsoName
= module
.output
->name
;
3445 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3448 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3449 GetCdFiles ( vCdFiles
);
3450 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3451 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3453 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3454 module
.name
.c_str ());
3455 fprintf ( fMakefile
,
3456 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3457 module
.name
.c_str (),
3458 backend
->GetFullName ( *isoboot
).c_str (),
3459 sourceFiles
.c_str (),
3461 cdDirectories
.c_str () );
3462 fprintf ( fMakefile
,
3463 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3464 backend
->GetFullName ( reactosDff
).c_str (),
3465 backend
->GetFullPath ( bootcdReactos
).c_str () );
3466 fprintf ( fMakefile
,
3467 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3468 backend
->GetFullName ( reactosDff
).c_str (),
3469 backend
->GetFullName ( reactosInf
).c_str (),
3470 backend
->GetFullPath ( bootcdReactos
).c_str ());
3471 fprintf ( fMakefile
,
3472 "\t-@${rm} %s 2>$(NUL)\n",
3473 backend
->GetFullName ( reactosInf
).c_str () );
3474 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3475 OutputCdfileCopyCommands ( bootcdDirectory
);
3477 if (module
.type
== IsoRegTest
)
3478 OutputCopyCommand ( srcunattend
, tarunattend
);
3480 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3481 fprintf ( fMakefile
,
3482 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3483 backend
->GetFullName ( *isoboot
).c_str (),
3484 backend
->GetFullPath ( bootcd
).c_str (),
3486 fprintf ( fMakefile
,
3491 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3492 const Module
& module_
)
3494 : MingwModuleHandler ( module_
)
3499 MingwLiveIsoModuleHandler::Process ()
3501 GenerateLiveIsoModuleTarget ();
3505 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3507 FileLocation
dir ( OutputDirectory
,
3510 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3514 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3515 string
& reactosDirectory
)
3517 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3519 const Module
& m
= *module
.project
.modules
[i
];
3524 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3525 FileLocation
destination ( OutputDirectory
,
3526 m
.install
->relative_path
.length () > 0
3527 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3528 : livecdDirectory
+ sSep
+ reactosDirectory
,
3530 OutputCopyCommand ( *aliasedModule
.output
,
3537 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3538 string
& reactosDirectory
)
3540 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3542 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3543 FileLocation
target ( OutputDirectory
,
3544 installfile
.target
->relative_path
.length () > 0
3545 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3546 : livecdDirectory
+ sSep
+ reactosDirectory
,
3547 installfile
.target
->name
);
3548 OutputCopyCommand ( *installfile
.source
, target
);
3553 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3555 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3556 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3557 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3558 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3559 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3560 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3562 FileLocation
livecdIni ( SourceDirectory
,
3563 "boot" + sSep
+ "bootdata",
3565 FileLocation
destination ( OutputDirectory
,
3568 OutputCopyCommand ( livecdIni
,
3573 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3575 FileLocation
freeldr ( OutputDirectory
,
3576 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3578 FileLocation
destination ( OutputDirectory
,
3579 livecdDirectory
+ sSep
+ "loader",
3581 OutputCopyCommand ( freeldr
,
3586 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3588 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3589 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3591 fprintf ( fMakefile
,
3592 "\t$(ECHO_MKHIVE)\n" );
3593 fprintf ( fMakefile
,
3594 "\t$(MKHIVE_TARGET) boot%cbootdata %s boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst.inf\n",
3595 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3596 cSep
, cSep
, cSep
, cSep
);
3600 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3602 string livecdDirectory
= module
.name
;
3603 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3608 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3612 throw InvalidOperationException ( module
.node
.location
.c_str(),
3614 "Invalid bootsector. module '%s' requires <bootsector>",
3615 module
.name
.c_str ());
3618 const FileLocation
*isoboot
= bootModule
->output
;
3621 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3622 Iso/LiveIso outputs are generated in code base root
3624 IsoName
= module
.output
->name
;
3626 string reactosDirectory
= "reactos";
3627 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3628 FileLocation
livecdReactos ( OutputDirectory
,
3629 livecdReactosNoFixup
,
3631 CLEAN_FILE ( livecdReactos
);
3633 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3634 module
.name
.c_str ());
3635 fprintf ( fMakefile
,
3636 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3637 module
.name
.c_str (),
3638 backend
->GetFullName ( *isoboot
) .c_str (),
3639 backend
->GetFullPath ( livecdReactos
).c_str () );
3640 OutputModuleCopyCommands ( livecdDirectory
,
3642 OutputNonModuleCopyCommands ( livecdDirectory
,
3644 OutputProfilesDirectoryCommands ( livecdDirectory
);
3645 OutputLoaderCommands ( livecdDirectory
);
3646 OutputRegistryCommands ( livecdDirectory
);
3647 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3648 fprintf ( fMakefile
,
3649 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3650 backend
->GetFullName( *isoboot
).c_str (),
3651 backend
->GetFullPath ( livecd
).c_str (),
3653 fprintf ( fMakefile
,
3658 MingwTestModuleHandler::MingwTestModuleHandler (
3659 const Module
& module_
)
3661 : MingwModuleHandler ( module_
)
3666 MingwTestModuleHandler::Process ()
3668 GenerateTestModuleTarget ();
3671 /* caller needs to delete the returned object */
3673 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3675 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3676 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3677 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3681 MingwTestModuleHandler::GenerateTestModuleTarget ()
3683 string
targetMacro ( GetTargetMacro ( module
) );
3684 string workingDirectory
= GetWorkingDirectory ( );
3685 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3687 GenerateImportLibraryTargetIfNeeded ();
3689 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3693 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3695 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3696 module
.GetEntryPoint(true).c_str (),
3697 module
.baseaddress
.c_str () );
3698 GenerateLinkerCommand ( dependencies
,
3704 GeneratePhonyTarget();
3709 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
3710 const Module
& module_
)
3712 : MingwModuleHandler ( module_
)
3717 MingwRpcServerModuleHandler::Process ()
3723 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
3724 const Module
& module_
)
3726 : MingwModuleHandler ( module_
)
3731 MingwRpcClientModuleHandler::Process ()
3737 MingwRpcProxyModuleHandler::MingwRpcProxyModuleHandler (
3738 const Module
& module_
)
3740 : MingwModuleHandler ( module_
)
3745 MingwRpcProxyModuleHandler::Process ()
3751 MingwAliasModuleHandler::MingwAliasModuleHandler (
3752 const Module
& module_
)
3754 : MingwModuleHandler ( module_
)
3759 MingwAliasModuleHandler::Process ()
3763 MingwMessageHeaderModuleHandler::MingwMessageHeaderModuleHandler (
3764 const Module
& module_
)
3766 : MingwModuleHandler ( module_
)
3771 MingwMessageHeaderModuleHandler::Process ()
3776 MingwIdlHeaderModuleHandler::MingwIdlHeaderModuleHandler (
3777 const Module
& module_
)
3779 : MingwModuleHandler ( module_
)
3784 MingwIdlHeaderModuleHandler::Process ()
3789 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3790 const Module
& module_
)
3792 : MingwModuleHandler ( module_
)
3797 MingwCabinetModuleHandler::Process ()
3799 string
targetMacro ( GetTargetMacro (module
) );
3803 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3804 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3805 targetMacro
.c_str (),
3806 backend
->GetFullPath ( *target_file
).c_str () );
3808 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3809 fprintf ( fMakefile
,
3810 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3811 targetMacro
.c_str (),
3812 module
.name
.c_str());
3815 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3816 const Module
& module_
)
3818 : MingwModuleHandler ( module_
)
3823 MingwElfExecutableModuleHandler::Process ()
3825 string
targetName ( module
.output
->name
);
3826 string
targetMacro ( GetTargetMacro (module
) );
3827 string workingDirectory
= GetWorkingDirectory ();
3828 string objectsMacro
= GetObjectsMacro ( module
);
3829 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3830 string libsMacro
= GetLibsMacro ();
3834 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3835 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3836 targetMacro
.c_str (),
3837 objectsMacro
.c_str (),
3838 linkDepsMacro
.c_str (),
3839 backend
->GetFullPath ( *target_file
).c_str () );
3841 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3843 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3844 module
.buildtype
.c_str(),
3845 objectsMacro
.c_str(),
3847 targetMacro
.c_str () );