2 * Copyright (C) 2005 Casper S. Hornstrup
3 * 2007-2008 Hervé Poussineau
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "../../pch.h"
23 #include "../../rbuild.h"
25 #include "modulehandler.h"
32 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
33 #define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
36 MingwModuleHandler::backend
= NULL
;
38 MingwModuleHandler::fMakefile
= NULL
;
42 const string
& filename
,
43 const string
& prefix
)
45 if ( !prefix
.length() )
48 const char* pfilename
= filename
.c_str();
49 const char* p1
= strrchr ( pfilename
, '/' );
50 const char* p2
= strrchr ( pfilename
, '\\' );
55 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
58 out
+= prefix
+ pfilename
;
63 GetTargetMacro ( const Module
& module
, bool with_dollar
)
65 string
s ( module
.name
);
69 return ssprintf ( "$(%s)", s
.c_str() );
73 MingwModuleHandler::MingwModuleHandler (
74 const Module
& module_
)
81 MingwModuleHandler::~MingwModuleHandler()
86 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
92 MingwModuleHandler::SetMakefile ( FILE* f
)
98 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
103 /*static*/ const FileLocation
*
104 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
106 switch ( file
->directory
)
108 case SourceDirectory
:
110 case IntermediateDirectory
:
111 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
113 case OutputDirectory
:
114 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
116 case InstallDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
120 throw InvalidOperationException ( __FILE__
,
122 "Invalid directory %d.",
129 /* caller needs to delete the returned object */
131 MingwModuleHandler::GetTargetFilename (
132 const Module
& module
,
133 string_list
* pclean_files
)
135 FileLocation
*target
= new FileLocation ( *module
.output
);
138 string_list
& clean_files
= *pclean_files
;
139 CLEAN_FILE ( *target
);
144 /* caller needs to delete the returned object */
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 FileLocation
*target
= new FileLocation ( *module
.dependency
);
153 string_list
& clean_files
= *pclean_files
;
154 CLEAN_FILE ( *target
);
159 /* caller needs to delete the returned object */
161 MingwModuleHandler::InstanciateHandler (
162 const Module
& module
,
163 MingwBackend
* backend
)
165 MingwModuleHandler
* handler
;
166 switch ( module
.type
)
169 case HostStaticLibrary
:
176 case EmbeddedTypeLib
:
178 handler
= new MingwModuleHandler( module
);
181 handler
= new MingwBuildToolModuleHandler ( module
);
184 handler
= new MingwKernelModuleHandler ( module
);
187 handler
= new MingwNativeCUIModuleHandler ( module
);
190 handler
= new MingwWin32CUIModuleHandler ( module
);
194 handler
= new MingwWin32GUIModuleHandler ( module
);
198 case KernelModeDriver
:
199 handler
= new MingwKernelModeDLLModuleHandler ( module
);
202 handler
= new MingwNativeDLLModuleHandler ( module
);
205 handler
= new MingwWin32DLLModuleHandler ( module
);
208 handler
= new MingwWin32OCXModuleHandler ( module
);
211 handler
= new MingwBootLoaderModuleHandler ( module
);
214 handler
= new MingwBootProgramModuleHandler ( module
);
217 handler
= new MingwIsoModuleHandler ( module
);
220 handler
= new MingwLiveIsoModuleHandler ( module
);
223 handler
= new MingwIsoModuleHandler ( module
);
226 handler
= new MingwLiveIsoModuleHandler ( module
);
229 handler
= new MingwTestModuleHandler ( module
);
232 handler
= new MingwAliasModuleHandler ( module
);
235 handler
= new MingwCabinetModuleHandler ( module
);
238 handler
= new MingwElfExecutableModuleHandler ( module
);
241 throw UnknownModuleTypeException (
242 module
.node
.location
,
250 MingwModuleHandler::GetWorkingDirectory () const
256 MingwModuleHandler::GetBasename ( const string
& filename
) const
258 size_t index
= filename
.find_last_of ( '.' );
259 if ( index
!= string::npos
)
260 return filename
.substr ( 0, index
);
265 MingwModuleHandler::GetCompilationUnitDependencies (
266 const CompilationUnit
& compilationUnit
) const
268 if ( compilationUnit
.GetFiles ().size () <= 1 )
270 vector
<string
> sourceFiles
;
271 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
273 const File
& file
= *compilationUnit
.GetFiles ()[i
];
274 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
276 return string ( " " ) + v2s ( sourceFiles
, 10 );
279 /* caller needs to delete the returned object */
281 MingwModuleHandler::GetModuleArchiveFilename () const
283 if ( IsStaticLibrary ( module
) )
284 return GetTargetFilename ( module
, NULL
);
285 return new FileLocation ( IntermediateDirectory
,
286 module
.output
->relative_path
,
287 ReplaceExtension ( module
.name
, ".temp.a" ) );
291 MingwModuleHandler::ReferenceObjects (
292 const Module
& module
)
294 if ( module
.type
== ObjectLibrary
)
296 if ( module
.type
== RpcServer
)
298 if ( module
.type
== RpcClient
)
300 if ( module
.type
== RpcProxy
)
302 if ( module
.type
== IdlHeader
)
304 if ( module
.type
== MessageHeader
)
310 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
311 const FileLocation
& destination
)
316 "\t${cp} %s %s 1>$(NUL)\n",
317 backend
->GetFullName ( source
).c_str (),
318 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
322 MingwModuleHandler::GetImportLibraryDependency (
323 const Module
& importedModule
)
326 if ( ReferenceObjects ( importedModule
) )
328 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
331 dep
= GetTargetMacro ( importedModule
);
332 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
334 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
335 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
336 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
337 if ( GetExtension ( *objectFilename
) == ".h" )
338 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
339 else if ( GetExtension ( *objectFilename
) == ".rc" )
340 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
345 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
346 dep
= backend
->GetFullName ( *library_target
);
347 delete library_target
;
353 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
354 string_list
& targets
)
356 if ( dependencyModule
.invocations
.size () > 0 )
358 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
360 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
361 invoke
.GetTargets ( targets
);
365 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
369 MingwModuleHandler::GetModuleDependencies (
370 string_list
& dependencies
)
372 size_t iend
= module
.dependencies
.size ();
377 for ( size_t i
= 0; i
< iend
; i
++ )
379 const Dependency
& dependency
= *module
.dependencies
[i
];
380 const Module
& dependencyModule
= *dependency
.dependencyModule
;
381 GetTargets ( dependencyModule
,
384 vector
<FileLocation
> v
;
385 GetDefinitionDependencies ( v
);
387 for ( size_t i
= 0; i
< v
.size (); i
++ )
389 const FileLocation
& file
= v
[i
];
390 dependencies
.push_back ( backend
->GetFullName ( file
) );
394 /* caller needs to delete the returned object */
396 MingwModuleHandler::GetObjectFilename (
397 const FileLocation
* sourceFile
,
398 const Module
& module
) const
400 DirectoryLocation destination_directory
;
402 string extension
= GetExtension ( *sourceFile
);
404 if ( module
.type
== BootSector
)
405 return new FileLocation ( *module
.output
);
406 else if ( extension
== ".rc" || extension
== ".RC" )
407 newExtension
= "_" + module
.name
+ ".coff";
408 else if ( extension
== ".mc" || extension
== ".MC" )
409 newExtension
= ".rc";
410 else if ( extension
== ".spec" || extension
== ".SPEC" )
411 newExtension
= ".stubs.o";
412 else if ( extension
== ".pspec" || extension
== ".PSPEC" )
413 newExtension
= ".stubs.o";
414 else if ( extension
== ".idl" || extension
== ".IDL" )
416 if ( module
.type
== RpcServer
)
417 newExtension
= "_s.o";
418 else if ( module
.type
== RpcClient
)
419 newExtension
= "_c.o";
420 else if ( module
.type
== RpcProxy
)
421 newExtension
= "_p.o";
426 newExtension
= "_" + module
.name
+ ".o";
428 if ( module
.type
== BootSector
)
429 destination_directory
= OutputDirectory
;
431 destination_directory
= IntermediateDirectory
;
433 const FileLocation
*obj_file
= new FileLocation(
434 destination_directory
,
435 sourceFile
->relative_path
,
436 ReplaceExtension ( sourceFile
->name
, newExtension
) );
437 PassThruCacheDirectory ( obj_file
);
443 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
445 return module
.name
+ "_clean";
449 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
451 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
453 Library
& library
= *module
.non_if_data
.libraries
[i
];
454 if ( library
.importedModule
->type
== ObjectLibrary
)
455 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
460 MingwModuleHandler::GenerateCleanTarget () const
462 if ( module
.type
== Alias
)
466 ".PHONY: %s_clean\n",
467 module
.name
.c_str() );
468 vector
<string
> referencedModuleNames
;
469 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
472 GetModuleCleanTarget ( module
).c_str(),
473 v2s ( referencedModuleNames
, 10 ).c_str () );
474 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
476 if ( ( i
+ 1 ) % 10 == 9 )
477 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
478 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
480 fprintf ( fMakefile
, " 2>$(NUL)\n" );
482 if( ProxyMakefile::GenerateProxyMakefile(module
) )
484 DirectoryLocation root
;
486 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
487 root
= SourceDirectory
;
489 root
= OutputDirectory
;
491 FileLocation
proxyMakefile ( root
,
492 module
.output
->relative_path
,
494 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
495 backend
->GetFullName ( proxyMakefile
).c_str () );
498 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
502 MingwModuleHandler::GenerateInstallTarget () const
504 if ( !module
.install
)
506 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
509 module
.name
.c_str (),
510 backend
->GetFullName ( *module
.install
).c_str () );
514 MingwModuleHandler::GenerateDependsTarget () const
517 ".PHONY: %s_depends\n",
518 module
.name
.c_str() );
520 "%s_depends: $(RBUILD_TARGET)\n",
521 module
.name
.c_str () );
523 "\t$(ECHO_RBUILD)\n" );
525 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
526 module
.name
.c_str () );
530 MingwModuleHandler::GetObjectFilenames ()
532 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
533 if ( compilationUnits
.size () == 0 )
536 string
objectFilenames ( "" );
537 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
539 if ( objectFilenames
.size () > 0 )
540 objectFilenames
+= " ";
541 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
542 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
543 objectFilenames
+= backend
->GetFullName ( *object_file
);
546 return objectFilenames
;
550 MingwModuleHandler::GenerateGccDefineParametersFromVector (
551 const vector
<Define
*>& defines
,
552 set
<string
>& used_defs
)
556 for ( size_t i
= 0; i
< defines
.size (); i
++ )
558 Define
& define
= *defines
[i
];
559 if (used_defs
.find(define
.name
) != used_defs
.end())
561 if (parameters
.length () > 0)
563 if (define
.name
.find('(') != string::npos
)
564 parameters
+= "$(QT)";
566 parameters
+= define
.name
;
567 if (define
.value
.length () > 0)
570 parameters
+= define
.value
;
572 if (define
.name
.find('(') != string::npos
)
573 parameters
+= "$(QT)";
574 used_defs
.insert(used_defs
.begin(),define
.name
);
580 MingwModuleHandler::GenerateGccDefineParameters () const
582 set
<string
> used_defs
;
583 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
, used_defs
);
584 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
, used_defs
);
585 if ( s
.length () > 0 )
594 MingwModuleHandler::ConcatenatePaths (
596 const string
& path2
) const
598 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
600 if ( path1
[path1
.length ()] == cSep
)
601 return path1
+ path2
;
603 return path1
+ cSep
+ path2
;
607 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
609 string parameters
, path_prefix
;
610 for ( size_t i
= 0; i
< includes
.size (); i
++ )
612 Include
& include
= *includes
[i
];
613 if ( parameters
.length () > 0 )
615 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
621 MingwModuleHandler::GenerateGccIncludeParameters () const
623 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
624 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
625 if ( s
.length () > 0 )
634 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
637 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
639 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
640 if ( compilerFlag
.compiler
== type
)
641 parameters
+= " " + compilerFlag
.flag
;
647 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
650 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
652 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
653 if ( parameters
.length () > 0 )
655 parameters
+= linkerFlag
.flag
;
661 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
662 const vector
<Library
*>& libraries
)
664 string
dependencies ( "" );
666 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
668 if ( wrap_count
++ == 5 )
669 dependencies
+= " \\\n\t\t", wrap_count
= 0;
670 else if ( dependencies
.size () > 0 )
672 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
678 MingwModuleHandler::GenerateLinkerParameters () const
680 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
684 MingwModuleHandler::GenerateMacro (
685 const char* assignmentOperation
,
687 const IfableData
& data
,
688 set
<const Define
*> *used_defs
,
689 bool generatingCompilerMacro
)
692 bool generateAssignment
;
694 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
695 if ( generatingCompilerMacro
)
696 generateAssignment
|= data
.compilerFlags
.size () > 0;
697 if ( generateAssignment
)
702 assignmentOperation
);
705 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
710 backend
->GetFullPath ( *pchFilename
).c_str () );
714 if ( generatingCompilerMacro
)
716 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
717 if ( compilerParameters
.size () > 0 )
722 compilerParameters
.c_str () );
725 for ( i
= 0; i
< data
.includes
.size(); i
++ )
727 const Include
& include
= *data
.includes
[i
];
728 const FileLocation
* includeDirectory
= include
.directory
;
732 backend
->GetFullPath ( *includeDirectory
).c_str() );
734 for ( i
= 0; i
< data
.defines
.size(); i
++ )
736 const Define
& define
= *data
.defines
[i
];
739 set
<const Define
*>::const_iterator last_define
;
740 for (last_define
= used_defs
->begin ();
741 last_define
!= used_defs
->end ();
744 if ( (*last_define
)->name
!= define
.name
)
746 if ( !define
.overridable
)
748 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
750 "Invalid override of define '%s', already defined at %s",
751 define
.name
.c_str (),
752 define
.node
->location
.c_str () );
754 if ( backend
->configuration
.Verbose
)
755 printf("%s: Overriding '%s' already defined at %s\n",
756 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
757 define
.node
->location
.c_str () );
760 if ( last_define
!= used_defs
->end () )
766 define
.name
.c_str() );
767 if (define
.value
.length () > 0)
771 define
.value
.c_str() );
773 used_defs
->insert( used_defs
->begin (), &define
);
775 if ( generateAssignment
)
777 fprintf ( fMakefile
, "\n" );
782 MingwModuleHandler::GenerateMacros (
783 const char* assignmentOperation
,
784 const IfableData
& data
,
785 const vector
<LinkerFlag
*>* linkerFlags
,
786 set
<const Define
*>& used_defs
)
788 GenerateMacro ( assignmentOperation
,
793 GenerateMacro ( assignmentOperation
,
799 if ( linkerFlags
!= NULL
)
801 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
802 if ( linkerParameters
.size () > 0 )
807 linkerflagsMacro
.c_str (),
809 linkerParameters
.c_str() );
813 if ( data
.libraries
.size () > 0 )
815 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
816 if ( deps
.size () > 0 )
829 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
831 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
832 delete compilationUnits
[i
];
836 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
841 MingwModuleHandler::GenerateSourceMacros (
842 const IfableData
& data
)
846 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
847 vector
<const FileLocation
*> headers
;
848 if ( compilationUnits
.size () > 0 )
853 sourcesMacro
.c_str () );
854 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
856 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
857 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
861 ( i
%10 == 9 ? " \\\n\t" : " " ),
862 backend
->GetFullName ( compilationName
).c_str () );
864 fprintf ( fMakefile
, "\n" );
867 vector
<CompilationUnit
*> sourceCompilationUnits
;
868 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
869 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
871 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
875 sourcesMacro
.c_str(),
876 backend
->GetFullName ( compilationName
).c_str () );
878 CleanupCompilationUnitVector ( sourceCompilationUnits
);
882 MingwModuleHandler::GenerateObjectMacros (
883 const IfableData
& data
)
886 const char* assignmentOperation
= "=";
888 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
889 vector
<const FileLocation
*> headers
;
890 vector
<const FileLocation
*> mcheaders
;
891 vector
<const FileLocation
*> mcresources
;
892 if ( compilationUnits
.size () > 0 )
894 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
896 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
897 if ( compilationUnit
.IsFirstFile () )
899 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
900 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
903 objectsMacro
.c_str(),
904 backend
->GetFullName ( *object_file
).c_str () );
906 assignmentOperation
= "+=";
913 objectsMacro
.c_str (),
914 assignmentOperation
);
915 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
917 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
918 if ( !compilationUnit
.IsFirstFile () )
920 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
921 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
922 if ( GetExtension ( *objectFilename
) == ".h" )
923 headers
.push_back ( objectFilename
);
924 else if ( GetExtension ( *objectFilename
) == ".rc" )
926 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
927 mcheaders
.push_back ( headerFilename
);
928 mcresources
.push_back ( objectFilename
);
935 ( i
%10 == 9 ? " \\\n\t" : " " ),
936 backend
->GetFullName ( *objectFilename
).c_str () );
937 delete objectFilename
;
941 fprintf ( fMakefile
, "\n" );
943 if ( headers
.size () > 0 )
948 module
.name
.c_str (),
949 assignmentOperation
);
950 for ( i
= 0; i
< headers
.size (); i
++ )
955 ( i
%10 == 9 ? " \\\n\t" : " " ),
956 backend
->GetFullName ( *headers
[i
] ).c_str () );
959 fprintf ( fMakefile
, "\n" );
962 if ( mcheaders
.size () > 0 )
967 module
.name
.c_str (),
968 assignmentOperation
);
969 for ( i
= 0; i
< mcheaders
.size (); i
++ )
974 ( i
%10 == 9 ? " \\\n\t" : " " ),
975 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
978 fprintf ( fMakefile
, "\n" );
981 if ( mcresources
.size () > 0 )
986 module
.name
.c_str (),
987 assignmentOperation
);
988 for ( i
= 0; i
< mcresources
.size (); i
++ )
993 ( i
%10 == 9 ? " \\\n\t" : " " ),
994 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
995 delete mcresources
[i
];
997 fprintf ( fMakefile
, "\n" );
1000 vector
<CompilationUnit
*> sourceCompilationUnits
;
1001 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1002 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1004 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1005 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1009 objectsMacro
.c_str(),
1010 backend
->GetFullName ( *object_file
).c_str () );
1013 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1016 /* caller needs to delete the returned object */
1018 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1020 if ( !module
.pch
|| !use_pch
)
1022 return new FileLocation ( IntermediateDirectory
,
1023 module
.pch
->file
->relative_path
,
1024 module
.pch
->file
->name
+ ".gch" );
1027 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1028 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1029 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1030 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1031 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1033 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1034 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1036 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1037 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1039 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1040 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1041 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1042 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1043 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1045 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1046 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1047 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1048 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1050 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1051 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1052 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1053 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1054 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1056 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1057 "\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"
1058 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1059 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1060 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1061 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1062 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1063 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"
1065 "\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",
1066 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1067 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1068 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1069 Rule
winebuildKMRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1070 "\t$(ECHO_WINEBLD)\n"
1071 "\t${gcc} -xc -E $(source) -I. > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
1072 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
1073 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c:\n"
1074 "\t${cp} $(NUL) $@ 1>$(NUL)\n"
1075 "$(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"
1077 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1078 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
1079 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1080 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1081 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1082 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1083 Rule
winebuildPCRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1084 "\t$(ECHO_WINEBLD)\n"
1085 "\t${gcc} -xc -E $(source) -I. > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
1086 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
1087 "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1088 "\t$(ECHO_WINEBLD)\n"
1089 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c --pedll $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
1090 "$(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"
1092 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1093 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
1094 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1095 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1096 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1097 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1098 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1099 "\t$(ECHO_WINEBLD)\n"
1100 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source)\n"
1101 "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1102 "\t$(ECHO_WINEBLD)\n"
1103 "\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"
1104 "$(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"
1106 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1107 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1108 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1109 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1110 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1111 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1112 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1114 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1115 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1116 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1117 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1118 "$(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"
1120 "\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"
1121 "$(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"
1123 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1124 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1125 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1126 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1127 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1128 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1129 "$(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"
1131 "\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"
1132 "$(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"
1134 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1135 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1136 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1137 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1138 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1139 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1140 "$(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"
1142 "\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"
1143 "$(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"
1145 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1146 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1147 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1148 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1149 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1150 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1151 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1153 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1154 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1155 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1156 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1158 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1159 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1160 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1161 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1163 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1164 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1165 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1166 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1168 "\t${gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1169 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1170 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1171 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1173 "\t${host_gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1174 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1175 Rule
emptyRule ( "", NULL
);
1178 MingwModuleHandler::GenerateGccCommand (
1179 const FileLocation
* sourceFile
,
1181 const string
& extraDependencies
)
1183 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1184 string dependencies
= extraDependencies
;
1187 string extension
= GetExtension ( *sourceFile
);
1188 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1189 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1191 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1195 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1199 /* WIDL generated headers may be used */
1200 vector
<FileLocation
> rpcDependencies
;
1201 GetRpcHeaderDependencies ( rpcDependencies
);
1202 if ( rpcDependencies
.size () > 0 )
1203 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1205 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1209 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1211 for ( size_t i
= 0; i
< module
.project
.non_if_data
.properties
.size (); i
++ )
1213 const Property
& property
= *module
.project
.non_if_data
.properties
[i
];
1214 if ( property
.name
== name
)
1215 return property
.value
;
1217 return string ( "" );
1220 /* caller needs to delete the returned object */
1222 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1224 string newname
= GetBasename ( base
->name
) + "_s.h";
1225 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1228 /* caller needs to delete the returned object */
1230 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1232 string newname
= GetBasename ( base
->name
) + "_c.h";
1233 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1236 /* caller needs to delete the returned object */
1238 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1240 string newname
= GetBasename ( base
->name
) + "_p.h";
1241 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1244 /* caller needs to delete the returned object */
1246 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1248 string newname
= GetBasename ( base
->name
) + ".h";
1249 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1252 /* caller needs to delete the returned object */
1254 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1256 string newname
= GetBasename ( base
->name
) + ".h";
1257 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1261 MingwModuleHandler::GenerateCommands (
1262 const CompilationUnit
& compilationUnit
,
1263 const string
& extraDependencies
)
1265 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1266 string extension
= GetExtension ( sourceFile
);
1267 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1276 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1277 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1278 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1279 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1280 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1281 { HostFalse
, Kernel
, ".spec", &winebuildKMRule
},
1282 { HostFalse
, KernelModeDLL
, ".spec", &winebuildKMRule
},
1283 { HostDontCare
, TypeDontCare
, ".pspec", &winebuildPCRule
},
1284 { HostDontCare
, TypeDontCare
, ".spec", &winebuildRule
},
1285 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1286 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1287 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1288 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1289 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1290 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1291 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1292 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1293 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1294 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1295 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1296 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1297 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1298 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1301 Rule
*customRule
= NULL
;
1303 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1305 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1307 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1309 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1311 customRule
= rules
[i
].rule
;
1315 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1317 GenerateGccCommand ( &sourceFile
,
1319 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1321 else if ( customRule
)
1322 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1325 throw InvalidOperationException ( __FILE__
,
1327 "Unsupported filename extension '%s' in file '%s'",
1329 backend
->GetFullName ( sourceFile
).c_str () );
1334 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1336 fprintf ( fMakefile
,
1337 "ifeq ($(ROS_BUILDMAP),full)\n" );
1339 FileLocation
mapFilename ( OutputDirectory
,
1340 module
.output
->relative_path
,
1341 GetBasename ( module
.output
->name
) + ".map" );
1342 CLEAN_FILE ( mapFilename
);
1344 fprintf ( fMakefile
,
1345 "\t$(ECHO_OBJDUMP)\n" );
1346 fprintf ( fMakefile
,
1347 "\t$(Q)${objdump} -d -S %s > %s\n",
1348 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1349 backend
->GetFullName ( mapFilename
).c_str () );
1351 fprintf ( fMakefile
,
1353 fprintf ( fMakefile
,
1354 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1356 fprintf ( fMakefile
,
1358 fprintf ( fMakefile
,
1359 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1360 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1361 backend
->GetFullName ( mapFilename
).c_str () );
1363 fprintf ( fMakefile
,
1366 fprintf ( fMakefile
,
1371 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1373 fprintf ( fMakefile
,
1374 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1376 FileLocation
nostripFilename ( OutputDirectory
,
1377 module
.output
->relative_path
,
1378 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1379 CLEAN_FILE ( nostripFilename
);
1381 OutputCopyCommand ( *module
.output
, nostripFilename
);
1383 fprintf ( fMakefile
,
1388 MergeStringVector ( const Backend
* backend
,
1389 const vector
<FileLocation
>& input
,
1390 vector
<string
>& output
)
1394 int wrap_count
= -1;
1395 for ( size_t i
= 0; i
< input
.size (); i
++ )
1397 if ( wrap_count
++ == wrap_at
)
1399 output
.push_back ( s
);
1403 else if ( s
.size () > 0)
1405 s
+= backend
->GetFullName ( input
[i
] );
1407 if ( s
.length () > 0 )
1408 output
.push_back ( s
);
1412 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1413 vector
<FileLocation
>& objectFiles
) const
1415 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1417 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1418 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1419 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1420 objectFiles
.push_back ( *object_file
);
1426 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1428 if ( backend
->configuration
.CleanAsYouGo
)
1430 vector
<FileLocation
> objectFiles
;
1431 GetObjectsVector ( module
.non_if_data
,
1433 vector
<string
> lines
;
1434 MergeStringVector ( backend
,
1437 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1439 fprintf ( fMakefile
,
1440 "\t-@${rm} %s 2>$(NUL)\n",
1441 lines
[i
].c_str () );
1447 MingwModuleHandler::GenerateRunRsymCode () const
1449 fprintf ( fMakefile
,
1450 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1451 fprintf ( fMakefile
,
1452 "\t$(ECHO_RSYM)\n" );
1453 fprintf ( fMakefile
,
1454 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1455 fprintf ( fMakefile
,
1460 MingwModuleHandler::GenerateRunStripCode () const
1462 fprintf ( fMakefile
,
1463 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1464 fprintf ( fMakefile
,
1465 "\t$(ECHO_STRIP)\n" );
1466 fprintf ( fMakefile
,
1467 "\t${strip} -s -x -X $@\n\n" );
1468 fprintf ( fMakefile
,
1473 MingwModuleHandler::GenerateLinkerCommand (
1474 const string
& dependencies
,
1475 const string
& linkerParameters
,
1476 const string
& pefixupParameters
)
1478 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1479 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1480 string linker
= "${ld}";
1481 string objectsMacro
= GetObjectsMacro ( module
);
1482 string libsMacro
= GetLibsMacro ();
1484 string
target_macro ( GetTargetMacro ( module
) );
1485 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1487 string linkerScriptArgument
;
1488 if ( module
.linkerScript
!= NULL
)
1489 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1491 linkerScriptArgument
= "";
1493 fprintf ( fMakefile
,
1494 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1495 target_macro
.c_str (),
1496 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1497 dependencies
.c_str (),
1498 target_folder
.c_str () );
1499 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1500 string
targetName ( module
.output
->name
);
1502 /* HACK: if we have C++ in kernel, link it with some user mode dlls (kernel32 + msvcrt) ... */
1503 static const string libsCppKernel
= " '$(shell ${TARGET_CC} -print-file-name=libkernel32.a)' '$(shell ${TARGET_CC} -print-file-name=libmsvcrt.a)'";
1505 if ( !module
.HasImportLibrary() )
1507 fprintf ( fMakefile
,
1508 "\t%s %s%s %s %s%s %s %s -o %s\n",
1510 linkerParameters
.c_str (),
1511 linkerScriptArgument
.c_str (),
1512 objectsMacro
.c_str (),
1513 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1514 module
.cplusplus
&& (module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
) ? libsCppKernel
.c_str () : "",
1516 GetLinkerMacro ().c_str (),
1517 target_macro
.c_str () );
1521 FileLocation
temp_exp ( TemporaryDirectory
,
1523 module
.name
+ ".temp.exp" );
1524 CLEAN_FILE ( temp_exp
);
1526 fprintf ( fMakefile
,
1527 "\t${dlltool} --dllname %s --def %s --output-exp %s%s%s\n",
1528 targetName
.c_str (),
1529 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1530 backend
->GetFullName ( temp_exp
).c_str (),
1531 module
.mangledSymbols
? "" : " --kill-at",
1532 module
.underscoreSymbols
? " --add-underscore" : "" );
1534 fprintf ( fMakefile
,
1535 "\t%s %s%s %s %s %s%s %s %s -o %s\n",
1537 linkerParameters
.c_str (),
1538 linkerScriptArgument
.c_str (),
1539 backend
->GetFullName ( temp_exp
).c_str (),
1540 objectsMacro
.c_str (),
1541 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1542 module
.cplusplus
&& (module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
) ? libsCppKernel
.c_str () : "",
1544 GetLinkerMacro ().c_str (),
1545 target_macro
.c_str () );
1547 fprintf ( fMakefile
,
1548 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1549 target_macro
.c_str (),
1550 pefixupParameters
.c_str() );
1552 fprintf ( fMakefile
,
1553 "\t-@${rm} %s 2>$(NUL)\n",
1554 backend
->GetFullName ( temp_exp
).c_str () );
1557 GenerateBuildMapCode ();
1558 GenerateBuildNonSymbolStrippedCode ();
1559 GenerateRunRsymCode ();
1560 GenerateRunStripCode ();
1561 GenerateCleanObjectsAsYouGoCode ();
1563 if ( definitionFilename
)
1564 delete definitionFilename
;
1569 MingwModuleHandler::GeneratePhonyTarget() const
1571 string
targetMacro ( GetTargetMacro ( module
) );
1572 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1574 fprintf ( fMakefile
,
1576 targetMacro
.c_str ());
1577 fprintf ( fMakefile
, "%s: | %s\n",
1578 targetMacro
.c_str (),
1579 backend
->GetFullPath ( *target_file
).c_str () );
1585 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1588 string moduleDependencies
;
1590 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1591 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1593 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1594 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1595 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1596 if ( GetExtension ( *objectFilename
) == ".h" )
1597 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1598 else if ( GetExtension ( *objectFilename
) == ".rc" )
1599 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1600 delete objectFilename
;
1603 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1605 GenerateCommands ( *compilationUnits
[i
],
1606 moduleDependencies
);
1607 fprintf ( fMakefile
,
1611 vector
<CompilationUnit
*> sourceCompilationUnits
;
1612 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1613 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1615 GenerateCommands ( *sourceCompilationUnits
[i
],
1616 moduleDependencies
);
1618 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1622 MingwModuleHandler::GenerateObjectFileTargets ()
1624 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1628 string cc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gcc}" : "${gcc}" );
1629 string cppc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gpp}" : "${gpp}" );
1631 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1632 CLEAN_FILE ( *pchFilename
);
1633 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1634 /* WIDL generated headers may be used */
1635 vector
<FileLocation
> rpcDependencies
;
1636 GetRpcHeaderDependencies ( rpcDependencies
);
1637 if ( rpcDependencies
.size () > 0 )
1638 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1639 fprintf ( fMakefile
,
1641 backend
->GetFullName ( *pchFilename
).c_str(),
1642 dependencies
.c_str(),
1643 backend
->GetFullPath ( *pchFilename
).c_str() );
1644 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1645 fprintf ( fMakefile
,
1646 "\t%s -o %s %s -g %s\n\n",
1647 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1648 backend
->GetFullName ( *pchFilename
).c_str(),
1649 cflagsMacro
.c_str(),
1650 backend
->GetFullName ( baseHeaderFile
).c_str() );
1654 GenerateObjectFileTargets ( module
.non_if_data
);
1655 fprintf ( fMakefile
, "\n" );
1658 /* caller needs to delete the returned object */
1660 MingwModuleHandler::GenerateArchiveTarget ()
1662 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1663 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1665 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1667 if ( IsStaticLibrary ( module
) && definitionFilename
)
1669 fprintf ( fMakefile
,
1670 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1671 module
.importLibrary
->dllname
.c_str (),
1672 backend
->GetFullName ( *definitionFilename
).c_str (),
1673 module
.mangledSymbols
? "" : " --kill-at",
1674 module
.underscoreSymbols
? " --add-underscore" : "" );
1677 if ( definitionFilename
)
1678 delete definitionFilename
;
1680 if(module
.type
== HostStaticLibrary
)
1681 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1683 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1685 GenerateCleanObjectsAsYouGoCode ();
1687 fprintf ( fMakefile
, "\n" );
1689 return archiveFilename
;
1693 MingwModuleHandler::GetCFlagsMacro () const
1695 return ssprintf ( "$(%s_CFLAGS)",
1696 module
.name
.c_str () );
1700 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1702 return ssprintf ( "$(%s_OBJS)",
1703 module
.name
.c_str () );
1707 MingwModuleHandler::GetLinkingDependenciesMacro () const
1709 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1713 MingwModuleHandler::GetLibsMacro () const
1715 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1719 MingwModuleHandler::GetLinkerMacro () const
1721 return ssprintf ( "$(%s_LFLAGS)",
1722 module
.name
.c_str () );
1726 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1728 if ( ReferenceObjects ( module
) )
1729 return GetObjectsMacro ( module
);
1732 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1733 string target
= backend
->GetFullName ( *target_file
).c_str ();
1740 MingwModuleHandler::GenerateSourceMacro ()
1742 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1744 GenerateSourceMacros ( module
.non_if_data
);
1746 // future references to the macro will be to get its values
1747 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1751 MingwModuleHandler::GenerateObjectMacro ()
1753 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1755 GenerateObjectMacros ( module
.non_if_data
);
1757 // future references to the macro will be to get its values
1758 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1762 MingwModuleHandler::GenerateTargetMacro ()
1764 fprintf ( fMakefile
,
1766 GetTargetMacro ( module
, false ).c_str (),
1767 GetModuleTargets ( module
).c_str () );
1771 MingwModuleHandler::GetRpcHeaderDependencies (
1772 vector
<FileLocation
>& dependencies
) const
1774 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1776 Library
& library
= *module
.non_if_data
.libraries
[i
];
1777 if ( library
.importedModule
->type
== RpcServer
||
1778 library
.importedModule
->type
== RpcClient
||
1779 library
.importedModule
->type
== RpcProxy
||
1780 library
.importedModule
->type
== IdlHeader
)
1782 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1784 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1785 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1786 string extension
= GetExtension ( sourceFile
);
1787 if ( extension
== ".idl" || extension
== ".IDL" )
1789 string basename
= GetBasename ( sourceFile
.name
);
1790 if ( library
.importedModule
->type
== RpcServer
)
1792 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1793 dependencies
.push_back ( *header
);
1796 if ( library
.importedModule
->type
== RpcClient
)
1798 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1799 dependencies
.push_back ( *header
);
1802 if ( library
.importedModule
->type
== RpcProxy
)
1804 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1805 dependencies
.push_back ( *header
);
1808 if ( library
.importedModule
->type
== IdlHeader
)
1810 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1811 dependencies
.push_back ( *header
);
1821 MingwModuleHandler::GenerateOtherMacros ()
1823 set
<const Define
*> used_defs
;
1825 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1826 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1827 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1828 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1829 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1830 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1831 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1836 &module
.linkerFlags
,
1839 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1843 module
.project
.non_if_data
,
1848 vector
<FileLocation
> s
;
1849 if ( module
.importLibrary
)
1851 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
1852 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
1854 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1855 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1856 string extension
= GetExtension ( sourceFile
);
1857 if ( extension
== ".spec" || extension
== ".SPEC" )
1858 GetSpecObjectDependencies ( s
, &sourceFile
);
1861 if ( s
.size () > 0 )
1866 linkDepsMacro
.c_str() );
1867 for ( size_t i
= 0; i
< s
.size(); i
++ )
1868 fprintf ( fMakefile
,
1870 backend
->GetFullName ( s
[i
] ).c_str () );
1871 fprintf ( fMakefile
, "\n" );
1874 string globalCflags
= "";
1875 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1876 globalCflags
+= " $(PROJECT_CFLAGS)";
1878 globalCflags
+= " -Wall -Wpointer-arith -D__REACTOS__";
1879 globalCflags
+= " -g";
1880 if ( backend
->usePipe
)
1881 globalCflags
+= " -pipe";
1882 if ( !module
.allowWarnings
)
1883 globalCflags
+= " -Werror";
1884 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1886 if ( module
.cplusplus
)
1887 globalCflags
+= " $(HOST_CPPFLAGS)";
1889 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
1893 if ( module
.cplusplus
)
1895 // HACK: use host headers when building C++
1896 globalCflags
+= " $(HOST_CPPFLAGS)";
1899 globalCflags
+= " -nostdinc";
1902 // Always force disabling of sibling calls optimisation for GCC
1903 // (TODO: Move to version-specific once this bug is fixed in GCC)
1904 globalCflags
+= " -fno-optimize-sibling-calls";
1909 cflagsMacro
.c_str (),
1910 globalCflags
.c_str () );
1912 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1916 "%s += $(PROJECT_RCFLAGS)\n",
1917 windresflagsMacro
.c_str () );
1921 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
1922 widlflagsMacro
.c_str (),
1923 module
.output
->relative_path
.c_str () );
1927 "%s_LFLAGS := $(PROJECT_LFLAGS) -g $(%s_LFLAGS)\n",
1928 module
.name
.c_str (),
1929 module
.name
.c_str () );
1935 "%s_LFLAGS += $(HOST_LFLAGS)\n",
1936 module
.name
.c_str () );
1942 linkDepsMacro
.c_str (),
1943 libsMacro
.c_str () );
1945 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
1946 if ( strlen( cflags
) > 0 )
1948 fprintf ( fMakefile
,
1950 cflagsMacro
.c_str (),
1954 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
1955 if ( strlen( nasmflags
) > 0 )
1957 fprintf ( fMakefile
,
1959 nasmflagsMacro
.c_str (),
1963 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
1964 if ( strlen( linkerflags
) > 0 )
1966 fprintf ( fMakefile
,
1968 linkerflagsMacro
.c_str (),
1972 if ( IsStaticLibrary ( module
) && module
.isStartupLib
)
1974 fprintf ( fMakefile
,
1975 "%s += -Wno-main\n\n",
1976 cflagsMacro
.c_str () );
1979 fprintf ( fMakefile
, "\n\n" );
1981 // future references to the macros will be to get their values
1982 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1983 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1984 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1988 MingwModuleHandler::GenerateRules ()
1990 string targetMacro
= GetTargetMacro ( module
);
1991 //CLEAN_FILE ( targetMacro );
1992 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
1994 // generate phony target for module name
1995 fprintf ( fMakefile
, ".PHONY: %s\n",
1996 module
.name
.c_str () );
1997 string dependencies
= GetTargetMacro ( module
);
1998 if ( module
.type
== Test
)
1999 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2000 fprintf ( fMakefile
, "%s: %s\n\n",
2001 module
.name
.c_str (),
2002 dependencies
.c_str () );
2003 if ( module
.type
== Test
)
2005 fprintf ( fMakefile
,
2007 targetMacro
.c_str ());
2010 if ( !ReferenceObjects ( module
) )
2012 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2016 GenerateObjectFileTargets ();
2020 MingwModuleHandler::GetInvocationDependencies (
2021 const Module
& module
,
2022 string_list
& dependencies
)
2024 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2026 Invoke
& invoke
= *module
.invocations
[i
];
2027 if ( invoke
.invokeModule
== &module
)
2028 /* Protect against circular dependencies */
2030 invoke
.GetTargets ( dependencies
);
2035 MingwModuleHandler::GenerateInvocations () const
2037 if ( module
.invocations
.size () == 0 )
2040 size_t iend
= module
.invocations
.size ();
2041 for ( size_t i
= 0; i
< iend
; i
++ )
2043 const Invoke
& invoke
= *module
.invocations
[i
];
2045 if ( invoke
.invokeModule
->type
!= BuildTool
)
2047 throw XMLInvalidBuildFileException (
2048 module
.node
.location
,
2049 "Only modules of type buildtool can be invoked." );
2052 string invokeTarget
= module
.GetInvocationTarget ( i
);
2053 string_list invoke_targets
;
2054 assert ( invoke_targets
.size() );
2055 invoke
.GetTargets ( invoke_targets
);
2056 fprintf ( fMakefile
,
2058 invokeTarget
.c_str () );
2059 fprintf ( fMakefile
,
2061 invokeTarget
.c_str () );
2062 size_t j
, jend
= invoke_targets
.size();
2063 for ( j
= 0; j
< jend
; j
++ )
2065 fprintf ( fMakefile
,
2067 invoke_targets
[i
].c_str () );
2069 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2070 for ( j
= 1; j
< jend
; j
++ )
2071 fprintf ( fMakefile
,
2073 invoke_targets
[i
].c_str () );
2074 fprintf ( fMakefile
,
2076 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2077 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2078 fprintf ( fMakefile
,
2080 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2081 invoke
.GetParameters ().c_str () );
2086 MingwModuleHandler::GetPreconditionDependenciesName () const
2088 return module
.name
+ "_precondition";
2092 MingwModuleHandler::GetDefaultDependencies (
2093 string_list
& dependencies
) const
2095 /* Avoid circular dependency */
2096 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2099 if (module
.name
!= "psdk" &&
2100 module
.name
!= "dxsdk")
2102 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2103 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2106 if (module
.name
!= "errcodes" &&
2107 module
.name
!= "bugcodes" &&
2108 module
.name
!= "ntstatus")
2110 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2111 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2112 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2115 ///* Check if any dependent library relies on the generated headers */
2116 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2118 // const Module& m = *module.project.modules[i];
2119 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2121 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2122 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2123 // string extension = GetExtension ( sourceFile );
2124 // if (extension == ".mc" || extension == ".MC" )
2126 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2127 // dependencies.push_back ( dependency );
2134 MingwModuleHandler::GeneratePreconditionDependencies ()
2136 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2137 string_list dependencies
;
2138 GetDefaultDependencies ( dependencies
);
2139 GetModuleDependencies ( dependencies
);
2141 GetInvocationDependencies ( module
, dependencies
);
2143 if ( dependencies
.size() )
2145 fprintf ( fMakefile
,
2147 preconditionDependenciesName
.c_str () );
2148 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2149 fprintf ( fMakefile
,
2151 dependencies
[i
].c_str () );
2152 fprintf ( fMakefile
, "\n\n" );
2155 fprintf ( fMakefile
, "\n" );
2159 MingwModuleHandler::IsWineModule () const
2161 if ( module
.importLibrary
== NULL
)
2164 size_t index
= module
.importLibrary
->source
->name
.rfind ( ".spec.def" );
2165 return ( index
!= string::npos
);
2168 /* caller needs to delete the returned object */
2170 MingwModuleHandler::GetDefinitionFilename () const
2172 if ( module
.importLibrary
== NULL
)
2175 DirectoryLocation directory
;
2176 if ( IsWineModule () )
2177 directory
= IntermediateDirectory
;
2179 directory
= SourceDirectory
;
2181 return new FileLocation ( directory
,
2182 module
.importLibrary
->source
->relative_path
,
2183 module
.importLibrary
->source
->name
);
2187 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2189 if ( module
.importLibrary
!= NULL
)
2191 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2192 const FileLocation
*defFilename
= GetDefinitionFilename ();
2193 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2195 vector
<FileLocation
> deps
;
2196 GetDefinitionDependencies ( deps
);
2198 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
2200 fprintf ( fMakefile
, "%s:",
2201 backend
->GetFullName ( *library_target
).c_str () );
2205 fprintf ( fMakefile
, " %s",
2206 backend
->GetFullName ( *defFilename
).c_str () );
2209 size_t i
, iend
= deps
.size();
2210 for ( i
= 0; i
< iend
; i
++ )
2211 fprintf ( fMakefile
, " %s",
2212 backend
->GetFullName ( deps
[i
] ).c_str () );
2214 fprintf ( fMakefile
, " | %s\n",
2215 backend
->GetFullPath ( *library_target
).c_str () );
2217 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2219 fprintf ( fMakefile
,
2220 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2221 module
.output
->name
.c_str (),
2222 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2224 backend
->GetFullName ( *library_target
).c_str (),
2225 module
.mangledSymbols
? "" : " --kill-at",
2226 module
.underscoreSymbols
? " --add-underscore" : "" );
2230 delete library_target
;
2235 MingwModuleHandler::GetSpecObjectDependencies (
2236 vector
<FileLocation
>& dependencies
,
2237 const FileLocation
*file
) const
2239 string basename
= GetBasename ( file
->name
);
2241 FileLocation
defDependency ( IntermediateDirectory
,
2242 file
->relative_path
,
2243 basename
+ ".spec.def" );
2244 dependencies
.push_back ( defDependency
);
2246 FileLocation
stubsDependency ( IntermediateDirectory
,
2247 file
->relative_path
,
2248 basename
+ ".stubs.c" );
2249 dependencies
.push_back ( stubsDependency
);
2253 MingwModuleHandler::GetMcObjectDependencies (
2254 vector
<FileLocation
>& dependencies
,
2255 const FileLocation
*file
) const
2257 string basename
= GetBasename ( file
->name
);
2259 FileLocation
defDependency ( IntermediateDirectory
,
2262 dependencies
.push_back ( defDependency
);
2264 FileLocation
stubsDependency ( IntermediateDirectory
,
2265 file
->relative_path
,
2267 dependencies
.push_back ( stubsDependency
);
2271 MingwModuleHandler::GetWidlObjectDependencies (
2272 vector
<FileLocation
>& dependencies
,
2273 const FileLocation
*file
) const
2275 string basename
= GetBasename ( file
->name
);
2276 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2278 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2279 file
->relative_path
,
2280 basename
+ "_s.c" );
2281 dependencies
.push_back ( serverSourceDependency
);
2282 dependencies
.push_back ( *generatedHeaderFilename
);
2284 delete generatedHeaderFilename
;
2288 MingwModuleHandler::GetDefinitionDependencies (
2289 vector
<FileLocation
>& dependencies
) const
2291 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2292 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2294 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2295 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2296 string extension
= GetExtension ( sourceFile
);
2297 if ( extension
== ".spec" || extension
== ".SPEC" )
2298 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2299 if ( extension
== ".idl" || extension
== ".IDL" )
2301 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2302 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2307 enum DebugSupportType
2314 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2320 case DebugKernelMode
:
2321 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2325 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2332 module
.non_if_data
.libraries
.push_back(pLibrary
);
2335 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2336 : MingwModuleHandler ( module_
)
2341 MingwBuildToolModuleHandler::Process ()
2343 GenerateBuildToolModuleTarget ();
2347 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2349 string
targetMacro ( GetTargetMacro (module
) );
2350 string objectsMacro
= GetObjectsMacro ( module
);
2351 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2352 string libsMacro
= GetLibsMacro ();
2357 if ( module
.cplusplus
)
2358 linker
= "${host_gpp}";
2360 linker
= "${host_gcc}";
2362 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2363 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2364 targetMacro
.c_str (),
2365 objectsMacro
.c_str (),
2366 linkDepsMacro
.c_str (),
2367 backend
->GetFullPath ( *target_file
).c_str () );
2368 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2369 fprintf ( fMakefile
,
2370 "\t%s %s -o $@ %s %s\n\n",
2372 GetLinkerMacro ().c_str (),
2373 objectsMacro
.c_str (),
2374 libsMacro
.c_str () );
2380 MingwKernelModuleHandler::MingwKernelModuleHandler (
2381 const Module
& module_
)
2383 : MingwModuleHandler ( module_
)
2388 MingwKernelModuleHandler::Process ()
2390 GenerateKernelModuleTarget ();
2394 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2396 string
targetMacro ( GetTargetMacro ( module
) );
2397 string workingDirectory
= GetWorkingDirectory ( );
2398 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2400 GenerateImportLibraryTargetIfNeeded ();
2402 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2406 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2408 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2409 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2410 module
.baseaddress
.c_str () );
2412 GenerateLinkerCommand ( dependencies
,
2413 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2418 GeneratePhonyTarget();
2423 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2424 const Module
& module_
)
2426 : MingwModuleHandler ( module_
)
2432 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2434 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2438 MingwKernelModeDLLModuleHandler::Process ()
2440 GenerateKernelModeDLLModuleTarget ();
2444 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2446 string
targetMacro ( GetTargetMacro ( module
) );
2447 string workingDirectory
= GetWorkingDirectory ();
2448 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2450 GenerateImportLibraryTargetIfNeeded ();
2452 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2456 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2458 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2459 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2460 module
.baseaddress
.c_str () );
2461 GenerateLinkerCommand ( dependencies
,
2467 GeneratePhonyTarget();
2472 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2473 const Module
& module_
)
2475 : MingwModuleHandler ( module_
)
2480 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2482 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2486 MingwNativeDLLModuleHandler::Process ()
2488 GenerateNativeDLLModuleTarget ();
2492 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2494 string
targetMacro ( GetTargetMacro (module
) );
2495 string workingDirectory
= GetWorkingDirectory ( );
2496 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2498 GenerateImportLibraryTargetIfNeeded ();
2500 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2504 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2506 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2507 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2508 module
.baseaddress
.c_str () );
2509 GenerateLinkerCommand ( dependencies
,
2515 GeneratePhonyTarget();
2520 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2521 const Module
& module_
)
2523 : MingwModuleHandler ( module_
)
2528 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2530 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2534 MingwNativeCUIModuleHandler::Process ()
2536 GenerateNativeCUIModuleTarget ();
2540 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2542 string
targetMacro ( GetTargetMacro (module
) );
2543 string workingDirectory
= GetWorkingDirectory ( );
2544 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2546 GenerateImportLibraryTargetIfNeeded ();
2548 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2552 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2554 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2555 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2556 module
.baseaddress
.c_str () );
2557 GenerateLinkerCommand ( dependencies
,
2563 GeneratePhonyTarget();
2568 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2569 const Module
& module_
)
2571 : MingwModuleHandler ( module_
)
2575 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2576 const Module
& module_
)
2578 : MingwModuleHandler ( module_
)
2583 LinksToCrt( Module
&module
)
2585 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
2587 Library
& library
= *module
.non_if_data
.libraries
[i
];
2588 if ( library
.name
== "libcntpr" || library
.name
== "crt" )
2595 MingwAddImplicitLibraries( Module
&module
)
2600 if ( module
.type
!= Win32DLL
2601 && module
.type
!= Win32OCX
2602 && module
.type
!= Win32CUI
2603 && module
.type
!= Win32GUI
2604 && module
.type
!= Win32SCR
)
2606 // no implicit libraries
2610 links_to_crt
= LinksToCrt ( module
);
2612 if ( !module
.isDefaultEntryPoint
)
2614 if ( module
.GetEntryPoint(false) == "0" )
2616 if ( !links_to_crt
)
2618 pLibrary
= new Library ( module
, "mingw_common" );
2619 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() , pLibrary
);
2621 pLibrary
= new Library ( module
, "msvcrt" );
2622 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2623 links_to_crt
= true;
2626 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2627 module
.non_if_data
.libraries
.push_back(pLibrary
);
2631 if ( module
.IsDLL () )
2633 //pLibrary = new Library ( module, "__mingw_dllmain" );
2634 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2638 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2639 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2642 pLibrary
= new Library ( module
, "mingw_common" );
2643 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() + 1, pLibrary
);
2645 if ( !links_to_crt
)
2647 // always link in msvcrt to get the basic routines
2648 pLibrary
= new Library ( module
, "msvcrt" );
2649 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2652 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2653 module
.non_if_data
.libraries
.push_back(pLibrary
);
2657 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2659 MingwAddImplicitLibraries ( module
);
2663 MingwWin32DLLModuleHandler::Process ()
2665 GenerateWin32DLLModuleTarget ();
2669 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2671 string
targetMacro ( GetTargetMacro (module
) );
2672 string workingDirectory
= GetWorkingDirectory ( );
2673 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2675 GenerateImportLibraryTargetIfNeeded ();
2677 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2681 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2683 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2684 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2685 module
.baseaddress
.c_str () );
2686 GenerateLinkerCommand ( dependencies
,
2692 GeneratePhonyTarget();
2698 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2700 MingwAddImplicitLibraries ( module
);
2704 MingwWin32OCXModuleHandler::Process ()
2706 GenerateWin32OCXModuleTarget ();
2710 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2712 string
targetMacro ( GetTargetMacro (module
) );
2713 string workingDirectory
= GetWorkingDirectory ( );
2714 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2716 GenerateImportLibraryTargetIfNeeded ();
2718 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2722 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2724 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2725 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2726 module
.baseaddress
.c_str () );
2727 GenerateLinkerCommand ( dependencies
,
2733 GeneratePhonyTarget();
2738 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2739 const Module
& module_
)
2741 : MingwModuleHandler ( module_
)
2746 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2748 MingwAddImplicitLibraries ( module
);
2752 MingwWin32CUIModuleHandler::Process ()
2754 GenerateWin32CUIModuleTarget ();
2758 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2760 string
targetMacro ( GetTargetMacro (module
) );
2761 string workingDirectory
= GetWorkingDirectory ( );
2762 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2764 GenerateImportLibraryTargetIfNeeded ();
2766 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2770 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2772 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2773 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2774 module
.baseaddress
.c_str () );
2775 GenerateLinkerCommand ( dependencies
,
2781 GeneratePhonyTarget();
2786 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2787 const Module
& module_
)
2789 : MingwModuleHandler ( module_
)
2794 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2796 MingwAddImplicitLibraries ( module
);
2800 MingwWin32GUIModuleHandler::Process ()
2802 GenerateWin32GUIModuleTarget ();
2806 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2808 string
targetMacro ( GetTargetMacro (module
) );
2809 string workingDirectory
= GetWorkingDirectory ( );
2810 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2812 GenerateImportLibraryTargetIfNeeded ();
2814 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2818 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2820 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2821 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2822 module
.baseaddress
.c_str () );
2823 GenerateLinkerCommand ( dependencies
,
2829 GeneratePhonyTarget();
2834 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2835 const Module
& module_
)
2837 : MingwModuleHandler ( module_
)
2842 MingwBootLoaderModuleHandler::Process ()
2844 GenerateBootLoaderModuleTarget ();
2848 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2850 string
targetName ( module
.output
->name
);
2851 string
targetMacro ( GetTargetMacro (module
) );
2852 string workingDirectory
= GetWorkingDirectory ();
2853 FileLocation
junk_tmp ( TemporaryDirectory
,
2855 module
.name
+ ".junk.tmp" );
2856 CLEAN_FILE ( junk_tmp
);
2857 string objectsMacro
= GetObjectsMacro ( module
);
2858 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2859 string libsMacro
= GetLibsMacro ();
2863 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2864 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2865 targetMacro
.c_str (),
2866 objectsMacro
.c_str (),
2867 linkDepsMacro
.c_str (),
2868 backend
->GetFullPath ( *target_file
).c_str () );
2870 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2872 if (Environment::GetArch() == "arm")
2874 fprintf ( fMakefile
,
2875 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
2876 backend
->GetFullName ( junk_tmp
).c_str (),
2877 objectsMacro
.c_str (),
2878 linkDepsMacro
.c_str (),
2879 GetLinkerMacro ().c_str ());
2883 fprintf ( fMakefile
,
2884 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
2885 backend
->GetFullName ( junk_tmp
).c_str (),
2886 objectsMacro
.c_str (),
2887 linkDepsMacro
.c_str (),
2888 GetLinkerMacro ().c_str ());
2890 fprintf ( fMakefile
,
2891 "\t${objcopy} -O binary %s $@\n",
2892 backend
->GetFullName ( junk_tmp
).c_str () );
2893 GenerateBuildMapCode ( &junk_tmp
);
2894 fprintf ( fMakefile
,
2895 "\t-@${rm} %s 2>$(NUL)\n",
2896 backend
->GetFullName ( junk_tmp
).c_str () );
2902 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2903 const Module
& module_
)
2904 : MingwModuleHandler ( module_
)
2909 MingwBootProgramModuleHandler::Process ()
2911 GenerateBootProgramModuleTarget ();
2915 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2917 string
targetName ( module
.output
->name
);
2918 string
targetMacro ( GetTargetMacro (module
) );
2919 string workingDirectory
= GetWorkingDirectory ();
2920 FileLocation
junk_tmp ( TemporaryDirectory
,
2922 module
.name
+ ".junk.tmp" );
2923 FileLocation
junk_elf ( TemporaryDirectory
,
2925 module
.name
+ ".junk.elf" );
2926 FileLocation
junk_cpy ( TemporaryDirectory
,
2928 module
.name
+ ".junk.elf" );
2929 CLEAN_FILE ( junk_tmp
);
2930 CLEAN_FILE ( junk_elf
);
2931 CLEAN_FILE ( junk_cpy
);
2932 string objectsMacro
= GetObjectsMacro ( module
);
2933 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2934 string libsMacro
= GetLibsMacro ();
2935 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
2939 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2940 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
2941 targetMacro
.c_str (),
2942 objectsMacro
.c_str (),
2943 linkDepsMacro
.c_str (),
2944 payload
->name
.c_str (),
2945 backend
->GetFullPath ( *target_file
).c_str () );
2947 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
2949 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
2950 module
.buildtype
.c_str (),
2951 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
2952 backend
->GetFullName ( junk_cpy
).c_str () );
2954 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
2955 module
.buildtype
.c_str (),
2956 backend
->GetFullName ( junk_cpy
).c_str (),
2957 backend
->GetFullName ( junk_tmp
).c_str () );
2959 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
2960 module
.buildtype
.c_str (),
2961 linkDepsMacro
.c_str (),
2962 backend
->GetFullName ( junk_tmp
).c_str (),
2963 backend
->GetFullName ( junk_elf
).c_str () );
2965 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
2966 module
.buildtype
.c_str (),
2967 backend
->GetFullName ( junk_elf
).c_str (),
2968 backend
->GetFullName ( *module
.output
) .c_str () );
2970 fprintf ( fMakefile
,
2971 "\t-@${rm} %s %s %s 2>$(NUL)\n",
2972 backend
->GetFullName ( junk_tmp
).c_str (),
2973 backend
->GetFullName ( junk_elf
).c_str (),
2974 backend
->GetFullName ( junk_cpy
).c_str () );
2980 MingwIsoModuleHandler::MingwIsoModuleHandler (
2981 const Module
& module_
)
2983 : MingwModuleHandler ( module_
)
2988 MingwIsoModuleHandler::Process ()
2990 GenerateIsoModuleTarget ();
2994 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2995 const string
& bootcdDirectory
)
2997 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2999 const Module
& m
= *module
.project
.modules
[i
];
3002 if ( m
.bootstrap
!= NULL
)
3004 FileLocation
targetFile ( OutputDirectory
,
3005 m
.bootstrap
->base
.length () > 0
3006 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3008 m
.bootstrap
->nameoncd
);
3009 OutputCopyCommand ( *m
.output
, targetFile
);
3015 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3016 const string
& bootcdDirectory
)
3018 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3020 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3021 FileLocation
targetFile ( OutputDirectory
,
3022 cdfile
.target
->relative_path
.length () > 0
3023 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3025 cdfile
.target
->name
);
3026 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3031 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3032 const string
& bootcdDirectory
)
3034 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3036 const Module
& m
= *module
.project
.modules
[i
];
3039 if ( m
.bootstrap
!= NULL
)
3041 FileLocation
targetDirectory ( OutputDirectory
,
3042 m
.bootstrap
->base
.length () > 0
3043 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3046 out
.push_back ( targetDirectory
);
3052 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3053 const string
& bootcdDirectory
)
3055 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3057 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3058 FileLocation
targetDirectory ( OutputDirectory
,
3059 cdfile
.target
->relative_path
.length () > 0
3060 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3063 out
.push_back( targetDirectory
);
3068 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3069 const string
& bootcdDirectory
)
3071 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3072 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3076 MingwIsoModuleHandler::GetBootstrapCdFiles (
3077 vector
<FileLocation
>& out
) const
3079 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3081 const Module
& m
= *module
.project
.modules
[i
];
3084 if ( m
.bootstrap
!= NULL
)
3086 out
.push_back ( *m
.output
);
3092 MingwIsoModuleHandler::GetNonModuleCdFiles (
3093 vector
<FileLocation
>& out
) const
3095 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3097 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3098 out
.push_back ( *cdfile
.source
);
3103 MingwIsoModuleHandler::GetCdFiles (
3104 vector
<FileLocation
>& out
) const
3106 GetBootstrapCdFiles ( out
);
3107 GetNonModuleCdFiles ( out
);
3111 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3113 string bootcdDirectory
= "cd";
3114 FileLocation
bootcd ( OutputDirectory
,
3117 FileLocation
bootcdReactos ( OutputDirectory
,
3118 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3120 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3121 vector
<FileLocation
> vCdDirectories
;
3124 FileLocation
srcunattend ( SourceDirectory
,
3125 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3127 FileLocation
tarunattend ( bootcdReactos
.directory
,
3128 bootcdReactos
.relative_path
,
3130 if (module
.type
== IsoRegTest
)
3131 vSourceFiles
.push_back ( srcunattend
);
3134 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3138 throw InvalidOperationException ( module
.node
.location
.c_str(),
3140 "Invalid bootsector. module '%s' requires <bootsector>",
3141 module
.name
.c_str ());
3144 const FileLocation
*isoboot
= bootModule
->output
;
3145 vSourceFiles
.push_back ( *isoboot
);
3147 // prepare reactos.dff and reactos.inf
3148 FileLocation
reactosDff ( SourceDirectory
,
3149 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3151 FileLocation
reactosInf ( bootcdReactos
.directory
,
3152 bootcdReactos
.relative_path
,
3155 vSourceFiles
.push_back ( reactosDff
);
3158 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3159 Iso/LiveIso outputs are generated in code base root
3161 string IsoName
= module
.output
->name
;
3163 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3166 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3167 GetCdFiles ( vCdFiles
);
3168 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3169 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3171 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3172 module
.name
.c_str ());
3173 fprintf ( fMakefile
,
3174 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3175 module
.name
.c_str (),
3176 backend
->GetFullName ( *isoboot
).c_str (),
3177 sourceFiles
.c_str (),
3179 cdDirectories
.c_str () );
3180 fprintf ( fMakefile
,
3181 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3182 backend
->GetFullName ( reactosDff
).c_str (),
3183 backend
->GetFullPath ( bootcdReactos
).c_str () );
3184 fprintf ( fMakefile
,
3185 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3186 backend
->GetFullName ( reactosDff
).c_str (),
3187 backend
->GetFullName ( reactosInf
).c_str (),
3188 backend
->GetFullPath ( bootcdReactos
).c_str ());
3189 fprintf ( fMakefile
,
3190 "\t-@${rm} %s 2>$(NUL)\n",
3191 backend
->GetFullName ( reactosInf
).c_str () );
3192 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3193 OutputCdfileCopyCommands ( bootcdDirectory
);
3195 if (module
.type
== IsoRegTest
)
3196 OutputCopyCommand ( srcunattend
, tarunattend
);
3198 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3199 fprintf ( fMakefile
,
3200 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3201 backend
->GetFullName ( *isoboot
).c_str (),
3202 backend
->GetFullPath ( bootcd
).c_str (),
3204 fprintf ( fMakefile
,
3209 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3210 const Module
& module_
)
3212 : MingwModuleHandler ( module_
)
3217 MingwLiveIsoModuleHandler::Process ()
3219 GenerateLiveIsoModuleTarget ();
3223 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3225 FileLocation
dir ( OutputDirectory
,
3228 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3232 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3233 string
& reactosDirectory
)
3235 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3237 const Module
& m
= *module
.project
.modules
[i
];
3242 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3243 FileLocation
destination ( OutputDirectory
,
3244 m
.install
->relative_path
.length () > 0
3245 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3246 : livecdDirectory
+ sSep
+ reactosDirectory
,
3248 OutputCopyCommand ( *aliasedModule
.output
,
3255 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3256 string
& reactosDirectory
)
3258 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3260 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3261 FileLocation
target ( OutputDirectory
,
3262 installfile
.target
->relative_path
.length () > 0
3263 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3264 : livecdDirectory
+ sSep
+ reactosDirectory
,
3265 installfile
.target
->name
);
3266 OutputCopyCommand ( *installfile
.source
, target
);
3271 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3273 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3274 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3275 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3276 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3277 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3278 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3280 FileLocation
livecdIni ( SourceDirectory
,
3281 "boot" + sSep
+ "bootdata",
3283 FileLocation
destination ( OutputDirectory
,
3286 OutputCopyCommand ( livecdIni
,
3291 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3293 FileLocation
freeldr ( OutputDirectory
,
3294 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3296 FileLocation
destination ( OutputDirectory
,
3297 livecdDirectory
+ sSep
+ "loader",
3299 OutputCopyCommand ( freeldr
,
3304 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3306 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3307 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3309 fprintf ( fMakefile
,
3310 "\t$(ECHO_MKHIVE)\n" );
3311 fprintf ( fMakefile
,
3312 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3313 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3314 cSep
, cSep
, cSep
, cSep
);
3318 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3320 string livecdDirectory
= module
.name
;
3321 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3326 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3330 throw InvalidOperationException ( module
.node
.location
.c_str(),
3332 "Invalid bootsector. module '%s' requires <bootsector>",
3333 module
.name
.c_str ());
3336 const FileLocation
*isoboot
= bootModule
->output
;
3339 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3340 Iso/LiveIso outputs are generated in code base root
3342 IsoName
= module
.output
->name
;
3344 string reactosDirectory
= "reactos";
3345 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3346 FileLocation
livecdReactos ( OutputDirectory
,
3347 livecdReactosNoFixup
,
3349 CLEAN_FILE ( livecdReactos
);
3351 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3352 module
.name
.c_str ());
3353 fprintf ( fMakefile
,
3354 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3355 module
.name
.c_str (),
3356 backend
->GetFullName ( *isoboot
) .c_str (),
3357 backend
->GetFullPath ( livecdReactos
).c_str () );
3358 OutputModuleCopyCommands ( livecdDirectory
,
3360 OutputNonModuleCopyCommands ( livecdDirectory
,
3362 OutputProfilesDirectoryCommands ( livecdDirectory
);
3363 OutputLoaderCommands ( livecdDirectory
);
3364 OutputRegistryCommands ( livecdDirectory
);
3365 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3366 fprintf ( fMakefile
,
3367 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3368 backend
->GetFullName( *isoboot
).c_str (),
3369 backend
->GetFullPath ( livecd
).c_str (),
3371 fprintf ( fMakefile
,
3376 MingwTestModuleHandler::MingwTestModuleHandler (
3377 const Module
& module_
)
3379 : MingwModuleHandler ( module_
)
3384 MingwTestModuleHandler::Process ()
3386 GenerateTestModuleTarget ();
3389 /* caller needs to delete the returned object */
3391 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3393 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3394 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3395 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3399 MingwTestModuleHandler::GenerateTestModuleTarget ()
3401 string
targetMacro ( GetTargetMacro ( module
) );
3402 string workingDirectory
= GetWorkingDirectory ( );
3403 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3405 GenerateImportLibraryTargetIfNeeded ();
3407 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3411 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3413 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3414 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3415 module
.baseaddress
.c_str () );
3416 GenerateLinkerCommand ( dependencies
,
3422 GeneratePhonyTarget();
3427 MingwAliasModuleHandler::MingwAliasModuleHandler (
3428 const Module
& module_
)
3430 : MingwModuleHandler ( module_
)
3435 MingwAliasModuleHandler::Process ()
3440 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3441 const Module
& module_
)
3443 : MingwModuleHandler ( module_
)
3448 MingwCabinetModuleHandler::Process ()
3450 string
targetMacro ( GetTargetMacro (module
) );
3454 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3455 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3456 targetMacro
.c_str (),
3457 backend
->GetFullPath ( *target_file
).c_str () );
3459 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3460 fprintf ( fMakefile
,
3461 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3462 targetMacro
.c_str (),
3463 module
.name
.c_str());
3466 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3467 const Module
& module_
)
3469 : MingwModuleHandler ( module_
)
3474 MingwElfExecutableModuleHandler::Process ()
3476 string
targetName ( module
.output
->name
);
3477 string
targetMacro ( GetTargetMacro (module
) );
3478 string workingDirectory
= GetWorkingDirectory ();
3479 string objectsMacro
= GetObjectsMacro ( module
);
3480 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3481 string libsMacro
= GetLibsMacro ();
3485 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3486 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3487 targetMacro
.c_str (),
3488 objectsMacro
.c_str (),
3489 linkDepsMacro
.c_str (),
3490 backend
->GetFullPath ( *target_file
).c_str () );
3492 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3494 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3495 module
.buildtype
.c_str(),
3496 objectsMacro
.c_str(),
3498 targetMacro
.c_str () );