2 * Copyright (C) 2005 Casper S. Hornstrup
3 * 2007-2008 Hervé Poussineau
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "../../pch.h"
23 #include "../../rbuild.h"
25 #include "modulehandler.h"
32 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
33 #define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
36 MingwModuleHandler::backend
= NULL
;
38 MingwModuleHandler::fMakefile
= NULL
;
42 const string
& filename
,
43 const string
& prefix
)
45 if ( !prefix
.length() )
48 const char* pfilename
= filename
.c_str();
49 const char* p1
= strrchr ( pfilename
, '/' );
50 const char* p2
= strrchr ( pfilename
, '\\' );
55 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
58 out
+= prefix
+ pfilename
;
63 GetTargetMacro ( const Module
& module
, bool with_dollar
)
65 string
s ( module
.name
);
69 return ssprintf ( "$(%s)", s
.c_str() );
73 MingwModuleHandler::MingwModuleHandler (
74 const Module
& module_
)
81 MingwModuleHandler::~MingwModuleHandler()
86 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
92 MingwModuleHandler::SetMakefile ( FILE* f
)
98 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
103 /*static*/ const FileLocation
*
104 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
106 switch ( file
->directory
)
108 case SourceDirectory
:
110 case IntermediateDirectory
:
111 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
113 case OutputDirectory
:
114 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
116 case InstallDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
120 throw InvalidOperationException ( __FILE__
,
122 "Invalid directory %d.",
129 /* caller needs to delete the returned object */
131 MingwModuleHandler::GetTargetFilename (
132 const Module
& module
,
133 string_list
* pclean_files
)
135 FileLocation
*target
= new FileLocation ( *module
.output
);
138 string_list
& clean_files
= *pclean_files
;
139 CLEAN_FILE ( *target
);
144 /* caller needs to delete the returned object */
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 FileLocation
*target
= new FileLocation ( *module
.dependency
);
153 string_list
& clean_files
= *pclean_files
;
154 CLEAN_FILE ( *target
);
159 /* caller needs to delete the returned object */
161 MingwModuleHandler::InstanciateHandler (
162 const Module
& module
,
163 MingwBackend
* backend
)
165 MingwModuleHandler
* handler
;
166 switch ( module
.type
)
169 handler
= new MingwBuildToolModuleHandler ( module
);
172 handler
= new MingwStaticLibraryModuleHandler ( module
);
174 case HostStaticLibrary
:
175 handler
= new MingwHostStaticLibraryModuleHandler ( module
);
178 handler
= new MingwObjectLibraryModuleHandler ( module
);
181 handler
= new MingwKernelModuleHandler ( module
);
184 handler
= new MingwNativeCUIModuleHandler ( module
);
187 handler
= new MingwWin32CUIModuleHandler ( module
);
191 handler
= new MingwWin32GUIModuleHandler ( module
);
194 handler
= new MingwKernelModeDLLModuleHandler ( module
);
197 handler
= new MingwNativeDLLModuleHandler ( module
);
200 handler
= new MingwWin32DLLModuleHandler ( module
);
203 handler
= new MingwWin32OCXModuleHandler ( module
);
205 case KernelModeDriver
:
206 handler
= new MingwKernelModeDriverModuleHandler ( module
);
209 handler
= new MingwBootLoaderModuleHandler ( module
);
212 handler
= new MingwBootSectorModuleHandler ( module
);
215 handler
= new MingwBootProgramModuleHandler ( module
);
218 handler
= new MingwIsoModuleHandler ( module
);
221 handler
= new MingwLiveIsoModuleHandler ( module
);
224 handler
= new MingwIsoModuleHandler ( module
);
227 handler
= new MingwLiveIsoModuleHandler ( module
);
230 handler
= new MingwTestModuleHandler ( module
);
233 handler
= new MingwRpcServerModuleHandler ( module
);
236 handler
= new MingwRpcClientModuleHandler ( module
);
239 handler
= new MingwRpcProxyModuleHandler ( module
);
242 handler
= new MingwAliasModuleHandler ( module
);
245 handler
= new MingwIdlHeaderModuleHandler ( module
);
247 case EmbeddedTypeLib
:
248 handler
= new MingwEmbeddedTypeLibModuleHandler ( module
);
251 handler
= new MingwElfExecutableModuleHandler ( module
);
254 throw UnknownModuleTypeException (
255 module
.node
.location
,
263 MingwModuleHandler::GetWorkingDirectory () const
269 MingwModuleHandler::GetBasename ( const string
& filename
) const
271 size_t index
= filename
.find_last_of ( '.' );
272 if ( index
!= string::npos
)
273 return filename
.substr ( 0, index
);
277 /* caller needs to delete the returned object */
279 MingwModuleHandler::GetActualSourceFilename (
280 const FileLocation
* file
) const
282 string filename
= file
->name
;
284 string extension
= GetExtension ( *file
);
285 if ( extension
== ".spec" || extension
== ".SPEC" )
287 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
);
288 FileLocation
*sourceFile
= new FileLocation (
289 objectFile
->directory
,
290 objectFile
->relative_path
,
291 ReplaceExtension ( objectFile
->name
, ".c" ) );
295 else if ( ( extension
== ".idl" || extension
== ".IDL" ) &&
296 ( module
.type
== RpcServer
|| module
.type
== RpcClient
|| module
.type
== RpcProxy
) )
298 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
);
299 FileLocation
*sourceFile
= new FileLocation (
300 objectFile
->directory
,
301 objectFile
->relative_path
,
302 ReplaceExtension ( objectFile
->name
, ".c" ) );
306 else if ( extension
== ".mc" || extension
== ".MC" )
308 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
);
309 FileLocation
*sourceFile
= new FileLocation (
310 objectFile
->directory
,
311 objectFile
->relative_path
,
312 ReplaceExtension ( objectFile
->name
, ".rc" ) );
317 return new FileLocation ( *file
);
321 MingwModuleHandler::GetExtraDependencies (
322 const FileLocation
*file
) const
324 string extension
= GetExtension ( *file
);
325 if ( extension
== ".idl" || extension
== ".IDL" )
327 const FileLocation
*header
;
328 switch ( module
.type
)
330 case RpcServer
: header
= GetRpcServerHeaderFilename ( file
); break;
331 case RpcClient
: header
= GetRpcClientHeaderFilename ( file
); break;
332 case RpcProxy
: header
= GetRpcProxyHeaderFilename ( file
); break;
333 case IdlHeader
: header
= GetIdlHeaderFilename ( file
); break;
334 default: header
= NULL
; break;
339 string dependencies
= backend
->GetFullName ( *header
);
341 return " " + dependencies
;
348 MingwModuleHandler::GetCompilationUnitDependencies (
349 const CompilationUnit
& compilationUnit
) const
351 if ( compilationUnit
.GetFiles ().size () <= 1 )
353 vector
<string
> sourceFiles
;
354 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
356 const File
& file
= *compilationUnit
.GetFiles ()[i
];
357 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
359 return string ( " " ) + v2s ( sourceFiles
, 10 );
362 /* caller needs to delete the returned object */
364 MingwModuleHandler::GetModuleArchiveFilename () const
366 if ( IsStaticLibrary ( module
) )
367 return GetTargetFilename ( module
, NULL
);
368 return new FileLocation ( IntermediateDirectory
,
369 module
.output
->relative_path
,
370 ReplaceExtension ( module
.name
, ".temp.a" ) );
374 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
376 string extension
= GetExtension ( file
.file
);
377 return ( extension
== ".spec" || extension
== ".SPEC" );
381 MingwModuleHandler::ReferenceObjects (
382 const Module
& module
)
384 if ( module
.type
== ObjectLibrary
)
386 if ( module
.type
== RpcServer
)
388 if ( module
.type
== RpcClient
)
390 if ( module
.type
== RpcProxy
)
392 if ( module
.type
== IdlHeader
)
398 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
399 const FileLocation
& destination
)
404 "\t${cp} %s %s 1>$(NUL)\n",
405 backend
->GetFullName ( source
).c_str (),
406 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
410 MingwModuleHandler::GetImportLibraryDependency (
411 const Module
& importedModule
)
414 if ( ReferenceObjects ( importedModule
) )
416 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
419 dep
= GetTargetMacro ( importedModule
);
420 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
422 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
423 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
424 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
425 if ( GetExtension ( *objectFilename
) == ".h" )
426 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
427 else if ( GetExtension ( *objectFilename
) == ".rc" )
428 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
433 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
434 dep
= backend
->GetFullName ( *library_target
);
435 delete library_target
;
441 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
442 string_list
& targets
)
444 if ( dependencyModule
.invocations
.size () > 0 )
446 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
448 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
449 invoke
.GetTargets ( targets
);
453 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
457 MingwModuleHandler::GetModuleDependencies (
458 string_list
& dependencies
)
460 size_t iend
= module
.dependencies
.size ();
465 for ( size_t i
= 0; i
< iend
; i
++ )
467 const Dependency
& dependency
= *module
.dependencies
[i
];
468 const Module
& dependencyModule
= *dependency
.dependencyModule
;
469 GetTargets ( dependencyModule
,
472 vector
<FileLocation
> v
;
473 GetDefinitionDependencies ( v
);
475 for ( size_t i
= 0; i
< v
.size (); i
++ )
477 const FileLocation
& file
= v
[i
];
478 dependencies
.push_back ( backend
->GetFullName ( file
) );
483 MingwModuleHandler::GetSourceFilenames ( vector
<FileLocation
>& list
,
484 bool includeGeneratedFiles
) const
488 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
489 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
491 if ( includeGeneratedFiles
|| !compilationUnits
[i
]->IsGeneratedFile () )
493 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
494 const FileLocation
* sourceFileLocation
= GetActualSourceFilename ( &compilationName
);
495 list
.push_back ( *sourceFileLocation
);
496 delete sourceFileLocation
;
499 // intentionally make a copy so that we can append more work in
500 // the middle of processing without having to go recursive
501 vector
<If
*> v
= module
.non_if_data
.ifs
;
502 for ( i
= 0; i
< v
.size (); i
++ )
506 // check for sub-ifs to add to list
507 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
508 for ( j
= 0; j
< ifs
.size (); j
++ )
509 v
.push_back ( ifs
[j
] );
510 const vector
<CompilationUnit
*>& compilationUnits
= rIf
.data
.compilationUnits
;
511 for ( j
= 0; j
< compilationUnits
.size (); j
++ )
513 CompilationUnit
& compilationUnit
= *compilationUnits
[j
];
514 if ( includeGeneratedFiles
|| !compilationUnit
.IsGeneratedFile () )
516 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
517 const FileLocation
* sourceFileLocation
= GetActualSourceFilename ( &compilationName
);
518 list
.push_back ( *sourceFileLocation
);
519 delete sourceFileLocation
;
526 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
527 vector
<FileLocation
>& list
) const
529 GetSourceFilenames ( list
, false );
532 /* caller needs to delete the returned object */
534 MingwModuleHandler::GetObjectFilename (
535 const FileLocation
* sourceFile
,
536 const Module
& module
) const
538 DirectoryLocation destination_directory
;
540 string extension
= GetExtension ( *sourceFile
);
542 if ( module
.type
== BootSector
)
543 return new FileLocation ( *module
.output
);
544 else if ( extension
== ".rc" || extension
== ".RC" )
545 newExtension
= "_" + module
.name
+ ".coff";
546 else if ( extension
== ".mc" || extension
== ".MC" )
547 newExtension
= ".rc";
548 else if ( extension
== ".spec" || extension
== ".SPEC" )
549 newExtension
= ".stubs.o";
550 else if ( extension
== ".idl" || extension
== ".IDL" )
552 if ( module
.type
== RpcServer
)
553 newExtension
= "_s.o";
554 else if ( module
.type
== RpcClient
)
555 newExtension
= "_c.o";
556 else if ( module
.type
== RpcProxy
)
557 newExtension
= "_p.o";
562 newExtension
= "_" + module
.name
+ ".o";
564 if ( module
.type
== BootSector
)
565 destination_directory
= OutputDirectory
;
567 destination_directory
= IntermediateDirectory
;
569 const FileLocation
*obj_file
= new FileLocation(
570 destination_directory
,
571 sourceFile
->relative_path
,
572 ReplaceExtension ( sourceFile
->name
, newExtension
) );
573 PassThruCacheDirectory ( obj_file
);
579 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
581 return module
.name
+ "_clean";
585 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
587 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
589 Library
& library
= *module
.non_if_data
.libraries
[i
];
590 if ( library
.importedModule
->type
== ObjectLibrary
)
591 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
596 MingwModuleHandler::GenerateCleanTarget () const
598 if ( module
.type
== Alias
)
602 ".PHONY: %s_clean\n",
603 module
.name
.c_str() );
604 vector
<string
> referencedModuleNames
;
605 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
608 GetModuleCleanTarget ( module
).c_str(),
609 v2s ( referencedModuleNames
, 10 ).c_str () );
610 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
612 if ( ( i
+ 1 ) % 10 == 9 )
613 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
614 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
616 fprintf ( fMakefile
, " 2>$(NUL)\n" );
618 if( ProxyMakefile::GenerateProxyMakefile(module
) )
620 DirectoryLocation root
;
622 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
623 root
= SourceDirectory
;
625 root
= OutputDirectory
;
627 FileLocation
proxyMakefile ( root
,
628 module
.output
->relative_path
,
630 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
631 backend
->GetFullName ( proxyMakefile
).c_str () );
634 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
638 MingwModuleHandler::GenerateInstallTarget () const
640 if ( !module
.install
)
642 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
645 module
.name
.c_str (),
646 backend
->GetFullName ( *module
.install
).c_str () );
650 MingwModuleHandler::GenerateDependsTarget () const
653 ".PHONY: %s_depends\n",
654 module
.name
.c_str() );
656 "%s_depends: $(RBUILD_TARGET)\n",
657 module
.name
.c_str () );
659 "\t$(ECHO_RBUILD)\n" );
661 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
662 module
.name
.c_str () );
666 MingwModuleHandler::GetObjectFilenames ()
668 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
669 if ( compilationUnits
.size () == 0 )
672 string
objectFilenames ( "" );
673 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
675 if ( objectFilenames
.size () > 0 )
676 objectFilenames
+= " ";
677 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
678 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
679 objectFilenames
+= backend
->GetFullName ( *object_file
);
682 return objectFilenames
;
686 MingwModuleHandler::GenerateGccDefineParametersFromVector (
687 const vector
<Define
*>& defines
,
688 set
<string
>& used_defs
)
692 for ( size_t i
= 0; i
< defines
.size (); i
++ )
694 Define
& define
= *defines
[i
];
695 if (used_defs
.find(define
.name
) != used_defs
.end())
697 if (parameters
.length () > 0)
699 if (define
.name
.find('(') != string::npos
)
700 parameters
+= "$(QT)";
702 parameters
+= define
.name
;
703 if (define
.value
.length () > 0)
706 parameters
+= define
.value
;
708 if (define
.name
.find('(') != string::npos
)
709 parameters
+= "$(QT)";
710 used_defs
.insert(used_defs
.begin(),define
.name
);
716 MingwModuleHandler::GenerateGccDefineParameters () const
718 set
<string
> used_defs
;
719 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
, used_defs
);
720 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
, used_defs
);
721 if ( s
.length () > 0 )
730 MingwModuleHandler::ConcatenatePaths (
732 const string
& path2
) const
734 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
736 if ( path1
[path1
.length ()] == cSep
)
737 return path1
+ path2
;
739 return path1
+ cSep
+ path2
;
743 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
745 string parameters
, path_prefix
;
746 for ( size_t i
= 0; i
< includes
.size (); i
++ )
748 Include
& include
= *includes
[i
];
749 if ( parameters
.length () > 0 )
751 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
757 MingwModuleHandler::GenerateGccIncludeParameters () const
759 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
760 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
761 if ( s
.length () > 0 )
770 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
773 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
775 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
776 if ( compilerFlag
.compiler
== type
)
777 parameters
+= " " + compilerFlag
.flag
;
783 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
786 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
788 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
789 if ( parameters
.length () > 0 )
791 parameters
+= linkerFlag
.flag
;
797 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
798 const vector
<Library
*>& libraries
)
800 string
dependencies ( "" );
802 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
804 if ( wrap_count
++ == 5 )
805 dependencies
+= " \\\n\t\t", wrap_count
= 0;
806 else if ( dependencies
.size () > 0 )
808 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
814 MingwModuleHandler::GenerateLinkerParameters () const
816 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
820 MingwModuleHandler::GenerateMacro (
821 const char* assignmentOperation
,
823 const IfableData
& data
,
824 set
<const Define
*> *used_defs
,
825 bool generatingCompilerMacro
)
828 bool generateAssignment
;
830 if ( generatingCompilerMacro
)
831 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0 || data
.compilerFlags
.size () > 0;
833 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
834 if ( generateAssignment
)
839 assignmentOperation
);
842 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
847 backend
->GetFullPath ( *pchFilename
).c_str () );
851 if ( generatingCompilerMacro
)
853 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
854 if ( compilerParameters
.size () > 0 )
859 compilerParameters
.c_str () );
862 for ( i
= 0; i
< data
.includes
.size(); i
++ )
864 const Include
& include
= *data
.includes
[i
];
865 const FileLocation
* includeDirectory
= include
.directory
;
869 backend
->GetFullPath ( *includeDirectory
).c_str() );
871 for ( i
= 0; i
< data
.defines
.size(); i
++ )
873 const Define
& define
= *data
.defines
[i
];
876 set
<const Define
*>::const_iterator last_define
;
877 for (last_define
= used_defs
->begin ();
878 last_define
!= used_defs
->end ();
881 if ( (*last_define
)->name
!= define
.name
)
883 if ( !define
.overridable
)
885 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
887 "Invalid override of define '%s', already defined at %s",
888 define
.name
.c_str (),
889 define
.node
->location
.c_str () );
891 if ( backend
->configuration
.Verbose
)
892 printf("%s: Overriding '%s' already defined at %s\n",
893 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
894 define
.node
->location
.c_str () );
897 if ( last_define
!= used_defs
->end () )
903 define
.name
.c_str() );
904 if (define
.value
.length () > 0)
908 define
.value
.c_str() );
910 used_defs
->insert( used_defs
->begin (), &define
);
912 if ( generateAssignment
)
914 fprintf ( fMakefile
, "\n" );
919 MingwModuleHandler::GenerateMacros (
920 const char* assignmentOperation
,
921 const IfableData
& data
,
922 const vector
<LinkerFlag
*>* linkerFlags
,
923 set
<const Define
*>& used_defs
)
927 GenerateMacro ( assignmentOperation
,
932 GenerateMacro ( assignmentOperation
,
938 if ( linkerFlags
!= NULL
)
940 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
941 if ( linkerParameters
.size () > 0 )
946 linkerflagsMacro
.c_str (),
948 linkerParameters
.c_str() );
952 if ( data
.libraries
.size () > 0 )
954 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
955 if ( deps
.size () > 0 )
966 const vector
<If
*>& ifs
= data
.ifs
;
967 for ( i
= 0; i
< ifs
.size(); i
++ )
970 if ( rIf
.data
.defines
.size()
971 || rIf
.data
.includes
.size()
972 || rIf
.data
.libraries
.size()
973 || rIf
.data
.compilationUnits
.size()
974 || rIf
.data
.compilerFlags
.size()
975 || rIf
.data
.ifs
.size() )
979 "%s (\"$(%s)\",\"%s\")\n",
980 rIf
.negated
? "ifneq" : "ifeq",
981 rIf
.property
.c_str(),
996 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
998 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
999 delete compilationUnits
[i
];
1003 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
1008 MingwModuleHandler::GenerateSourceMacros (
1009 const char* assignmentOperation
,
1010 const IfableData
& data
)
1014 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1015 vector
<const FileLocation
*> headers
;
1016 if ( compilationUnits
.size () > 0 )
1021 sourcesMacro
.c_str (),
1022 assignmentOperation
);
1023 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
1025 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1026 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1030 ( i
%10 == 9 ? " \\\n\t" : " " ),
1031 backend
->GetFullName ( compilationName
).c_str () );
1033 fprintf ( fMakefile
, "\n" );
1036 const vector
<If
*>& ifs
= data
.ifs
;
1037 for ( i
= 0; i
< ifs
.size(); i
++ )
1040 if ( rIf
.data
.defines
.size()
1041 || rIf
.data
.includes
.size()
1042 || rIf
.data
.libraries
.size()
1043 || rIf
.data
.compilationUnits
.size()
1044 || rIf
.data
.compilerFlags
.size()
1045 || rIf
.data
.ifs
.size() )
1049 "%s (\"$(%s)\",\"%s\")\n",
1050 rIf
.negated
? "ifneq" : "ifeq",
1051 rIf
.property
.c_str(),
1052 rIf
.value
.c_str() );
1053 GenerateSourceMacros (
1062 vector
<CompilationUnit
*> sourceCompilationUnits
;
1063 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1064 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1066 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1070 sourcesMacro
.c_str(),
1071 backend
->GetFullName ( compilationName
).c_str () );
1073 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1077 MingwModuleHandler::GenerateObjectMacros (
1078 const char* assignmentOperation
,
1079 const IfableData
& data
)
1083 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1084 vector
<const FileLocation
*> headers
;
1085 vector
<const FileLocation
*> mcheaders
;
1086 vector
<const FileLocation
*> mcresources
;
1087 if ( compilationUnits
.size () > 0 )
1089 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1091 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1092 if ( compilationUnit
.IsFirstFile () )
1094 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1095 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1096 fprintf ( fMakefile
,
1098 objectsMacro
.c_str(),
1099 backend
->GetFullName ( *object_file
).c_str (),
1100 objectsMacro
.c_str() );
1107 objectsMacro
.c_str (),
1108 assignmentOperation
);
1109 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
1111 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1112 if ( !compilationUnit
.IsFirstFile () )
1114 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1115 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1116 if ( GetExtension ( *objectFilename
) == ".h" )
1117 headers
.push_back ( objectFilename
);
1118 else if ( GetExtension ( *objectFilename
) == ".rc" )
1120 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
1121 mcheaders
.push_back ( headerFilename
);
1122 mcresources
.push_back ( objectFilename
);
1129 ( i
%10 == 9 ? " \\\n\t" : " " ),
1130 backend
->GetFullName ( *objectFilename
).c_str () );
1131 delete objectFilename
;
1135 fprintf ( fMakefile
, "\n" );
1137 if ( headers
.size () > 0 )
1142 module
.name
.c_str (),
1143 assignmentOperation
);
1144 for ( i
= 0; i
< headers
.size (); i
++ )
1149 ( i
%10 == 9 ? " \\\n\t" : " " ),
1150 backend
->GetFullName ( *headers
[i
] ).c_str () );
1153 fprintf ( fMakefile
, "\n" );
1156 if ( mcheaders
.size () > 0 )
1161 module
.name
.c_str (),
1162 assignmentOperation
);
1163 for ( i
= 0; i
< mcheaders
.size (); i
++ )
1168 ( i
%10 == 9 ? " \\\n\t" : " " ),
1169 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
1170 delete mcheaders
[i
];
1172 fprintf ( fMakefile
, "\n" );
1175 if ( mcresources
.size () > 0 )
1180 module
.name
.c_str (),
1181 assignmentOperation
);
1182 for ( i
= 0; i
< mcresources
.size (); i
++ )
1187 ( i
%10 == 9 ? " \\\n\t" : " " ),
1188 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
1189 delete mcresources
[i
];
1191 fprintf ( fMakefile
, "\n" );
1194 const vector
<If
*>& ifs
= data
.ifs
;
1195 for ( i
= 0; i
< ifs
.size(); i
++ )
1198 if ( rIf
.data
.defines
.size()
1199 || rIf
.data
.includes
.size()
1200 || rIf
.data
.libraries
.size()
1201 || rIf
.data
.compilationUnits
.size()
1202 || rIf
.data
.compilerFlags
.size()
1203 || rIf
.data
.ifs
.size() )
1207 "%s (\"$(%s)\",\"%s\")\n",
1208 rIf
.negated
? "ifneq" : "ifeq",
1209 rIf
.property
.c_str(),
1210 rIf
.value
.c_str() );
1211 GenerateObjectMacros (
1220 vector
<CompilationUnit
*> sourceCompilationUnits
;
1221 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1222 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1224 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1225 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1229 objectsMacro
.c_str(),
1230 backend
->GetFullName ( *object_file
).c_str () );
1233 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1236 /* caller needs to delete the returned object */
1238 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1240 if ( !module
.pch
|| !use_pch
)
1242 return new FileLocation ( IntermediateDirectory
,
1243 module
.pch
->file
->relative_path
,
1244 ReplaceExtension ( module
.pch
->file
->name
, "_" + module
.name
+ ".gch" ) );
1247 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1248 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1249 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1250 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1251 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1253 Rule
gasRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1255 "\t${gcc} -x assembler-with-cpp -c $< -o $@ -D__ASM__ $($(module_name)_CFLAGS)\n",
1256 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1257 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1258 Rule
bootRule ( "$(module_output): $(source) ${$(module_name)_precondition}$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1260 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1261 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1262 Rule
nasmRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1264 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1265 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1266 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1267 Rule
windresRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source) ${$(module_name)_precondition}$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1269 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1270 "\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"
1271 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1272 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1273 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1274 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1275 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1276 Rule
wmcRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(WMC_TARGET) $(source)\n"
1278 "\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",
1279 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc", "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h", NULL
);
1280 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source) ${$(module_name)_precondition}$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1281 "\t$(ECHO_WINEBLD)\n"
1282 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source_path)$(SEP)$(source_name_noext).spec\n"
1283 "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1284 "\t$(ECHO_WINEBLD)\n"
1285 "\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"
1286 "$(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"
1288 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1289 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1290 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1291 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1292 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1293 Rule
widlHeaderRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source) ${$(module_name)_precondition}$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1295 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1296 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1297 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1298 Rule
widlServerRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h: $(source) ${$(module_name)_precondition}$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1300 "\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"
1301 "$(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"
1303 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1304 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1305 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1306 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1307 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1308 Rule
widlClientRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h: $(source) ${$(module_name)_precondition}$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1310 "\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"
1311 "$(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"
1313 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1314 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1315 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1316 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1317 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1318 Rule
widlProxyRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h: $(source) ${$(module_name)_precondition}$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1320 "\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"
1321 "$(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"
1323 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1324 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1325 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1326 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1327 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1328 Rule
widlTlbRule ( "$(OUTPUT)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source) ${$(module_name)_precondition}$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1330 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1331 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1332 Rule
gccRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1334 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1335 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1336 Rule
gccHostRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1338 "\t${host_gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1339 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1340 Rule
gppRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1342 "\t${gpp} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1343 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1344 Rule
gppHostRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1346 "\t${host_gpp} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1347 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1350 MingwModuleHandler::GenerateGccCommand (
1351 const FileLocation
* sourceFile
,
1353 const string
& extraDependencies
)
1355 const FileLocation
*generatedSourceFileName
= GetActualSourceFilename ( sourceFile
);
1356 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1357 string dependencies
= extraDependencies
;
1360 string extension
= GetExtension ( *sourceFile
);
1361 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1362 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1364 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1368 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1372 /* WIDL generated headers may be used */
1373 vector
<FileLocation
> rpcDependencies
;
1374 GetRpcHeaderDependencies ( rpcDependencies
);
1375 if ( rpcDependencies
.size () > 0 )
1376 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1378 rule
->Execute ( fMakefile
, backend
, module
, generatedSourceFileName
, clean_files
, dependencies
, flags
);
1380 delete generatedSourceFileName
;
1384 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1386 for ( size_t i
= 0; i
< module
.project
.non_if_data
.properties
.size (); i
++ )
1388 const Property
& property
= *module
.project
.non_if_data
.properties
[i
];
1389 if ( property
.name
== name
)
1390 return property
.value
;
1392 return string ( "" );
1395 /* caller needs to delete the returned object */
1397 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1399 string newname
= GetBasename ( base
->name
) + "_s.h";
1400 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1403 /* caller needs to delete the returned object */
1405 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1407 string newname
= GetBasename ( base
->name
) + "_c.h";
1408 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1411 /* caller needs to delete the returned object */
1413 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1415 string newname
= GetBasename ( base
->name
) + "_p.h";
1416 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1419 /* caller needs to delete the returned object */
1421 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1423 string newname
= GetBasename ( base
->name
) + ".h";
1424 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1427 /* caller needs to delete the returned object */
1429 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1431 string newname
= GetBasename ( base
->name
) + ".h";
1432 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1436 MingwModuleHandler::GenerateCommands (
1437 const CompilationUnit
& compilationUnit
,
1438 const string
& extraDependencies
)
1440 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1441 string extension
= GetExtension ( sourceFile
);
1442 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1451 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1452 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1453 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1454 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1455 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1456 { HostDontCare
, TypeDontCare
, ".spec", &winebuildRule
},
1457 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1458 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1459 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1460 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1461 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1462 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1463 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1464 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1465 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1466 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1467 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1468 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1469 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1472 Rule
*customRule
= NULL
;
1474 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1476 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= module
.host
)
1478 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1480 if ( rules
[i
].extension
!= extension
)
1482 customRule
= rules
[i
].rule
;
1486 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1488 GenerateGccCommand ( &sourceFile
,
1490 GetCompilationUnitDependencies ( compilationUnit
) + GetExtraDependencies ( &sourceFile
) + extraDependencies
);
1492 else if ( customRule
)
1493 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1496 throw InvalidOperationException ( __FILE__
,
1498 "Unsupported filename extension '%s' in file '%s'",
1500 backend
->GetFullName ( sourceFile
).c_str () );
1505 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1507 fprintf ( fMakefile
,
1508 "ifeq ($(ROS_BUILDMAP),full)\n" );
1510 FileLocation
mapFilename ( OutputDirectory
,
1511 module
.output
->relative_path
,
1512 GetBasename ( module
.output
->name
) + ".map" );
1513 CLEAN_FILE ( mapFilename
);
1515 fprintf ( fMakefile
,
1516 "\t$(ECHO_OBJDUMP)\n" );
1517 fprintf ( fMakefile
,
1518 "\t$(Q)${objdump} -d -S %s > %s\n",
1519 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1520 backend
->GetFullName ( mapFilename
).c_str () );
1522 fprintf ( fMakefile
,
1524 fprintf ( fMakefile
,
1525 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1527 fprintf ( fMakefile
,
1529 fprintf ( fMakefile
,
1530 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1531 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1532 backend
->GetFullName ( mapFilename
).c_str () );
1534 fprintf ( fMakefile
,
1537 fprintf ( fMakefile
,
1542 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1544 fprintf ( fMakefile
,
1545 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1547 FileLocation
nostripFilename ( OutputDirectory
,
1548 module
.output
->relative_path
,
1549 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1550 CLEAN_FILE ( nostripFilename
);
1552 OutputCopyCommand ( *module
.output
, nostripFilename
);
1554 fprintf ( fMakefile
,
1559 MergeStringVector ( const Backend
* backend
,
1560 const vector
<FileLocation
>& input
,
1561 vector
<string
>& output
)
1565 int wrap_count
= -1;
1566 for ( size_t i
= 0; i
< input
.size (); i
++ )
1568 if ( wrap_count
++ == wrap_at
)
1570 output
.push_back ( s
);
1574 else if ( s
.size () > 0)
1576 s
+= backend
->GetFullName ( input
[i
] );
1578 if ( s
.length () > 0 )
1579 output
.push_back ( s
);
1583 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1584 vector
<FileLocation
>& objectFiles
) const
1586 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1588 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1589 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1590 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1591 objectFiles
.push_back ( *object_file
);
1597 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1599 if ( backend
->configuration
.CleanAsYouGo
)
1601 vector
<FileLocation
> objectFiles
;
1602 GetObjectsVector ( module
.non_if_data
,
1604 vector
<string
> lines
;
1605 MergeStringVector ( backend
,
1608 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1610 fprintf ( fMakefile
,
1611 "\t-@${rm} %s 2>$(NUL)\n",
1612 lines
[i
].c_str () );
1618 MingwModuleHandler::GenerateRunRsymCode () const
1620 fprintf ( fMakefile
,
1621 "\t$(ECHO_RSYM)\n" );
1622 fprintf ( fMakefile
,
1623 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1627 MingwModuleHandler::GenerateRunStripCode () const
1629 fprintf ( fMakefile
,
1630 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1631 fprintf ( fMakefile
,
1632 "\t$(ECHO_STRIP)\n" );
1633 fprintf ( fMakefile
,
1634 "\t${strip} -s -x -X $@\n\n" );
1635 fprintf ( fMakefile
,
1640 MingwModuleHandler::GenerateLinkerCommand (
1641 const string
& dependencies
,
1642 const string
& linkerParameters
,
1643 const string
& pefixupParameters
)
1645 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1646 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1647 string linker
= module
.cplusplus
? "${gpp}" : "${gcc}";
1648 string objectsMacro
= GetObjectsMacro ( module
);
1649 string libsMacro
= GetLibsMacro ();
1651 string
target_macro ( GetTargetMacro ( module
) );
1652 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1654 string linkerScriptArgument
;
1655 if ( module
.linkerScript
!= NULL
)
1656 linkerScriptArgument
= ssprintf ( " -Wl,-T,%s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1658 linkerScriptArgument
= "";
1660 fprintf ( fMakefile
,
1661 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1662 target_macro
.c_str (),
1663 backend
->GetFullName ( *definitionFilename
).c_str (),
1664 dependencies
.c_str (),
1665 target_folder
.c_str () );
1666 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1667 string
targetName ( module
.output
->name
);
1669 if ( !module
.IsDLL () )
1671 fprintf ( fMakefile
,
1672 "\t%s %s%s -o %s %s %s %s\n",
1674 linkerParameters
.c_str (),
1675 linkerScriptArgument
.c_str (),
1676 target_macro
.c_str (),
1677 objectsMacro
.c_str (),
1679 GetLinkerMacro ().c_str () );
1681 else if ( module
.HasImportLibrary () )
1683 FileLocation
temp_exp ( TemporaryDirectory
,
1685 module
.name
+ ".temp.exp" );
1686 CLEAN_FILE ( temp_exp
);
1688 fprintf ( fMakefile
,
1689 "\t${dlltool} --dllname %s --def %s --output-exp %s%s%s\n",
1690 targetName
.c_str (),
1691 backend
->GetFullName ( *definitionFilename
).c_str (),
1692 backend
->GetFullName ( temp_exp
).c_str (),
1693 module
.mangledSymbols
? "" : " --kill-at",
1694 module
.underscoreSymbols
? " --add-underscore" : "" );
1696 fprintf ( fMakefile
,
1697 "\t%s %s%s %s -o %s %s %s %s\n",
1699 linkerParameters
.c_str (),
1700 linkerScriptArgument
.c_str (),
1701 backend
->GetFullName ( temp_exp
).c_str (),
1702 target_macro
.c_str (),
1703 objectsMacro
.c_str (),
1705 GetLinkerMacro ().c_str () );
1707 fprintf ( fMakefile
,
1708 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1709 target_macro
.c_str (),
1710 pefixupParameters
.c_str() );
1712 fprintf ( fMakefile
,
1713 "\t-@${rm} %s 2>$(NUL)\n",
1714 backend
->GetFullName ( temp_exp
).c_str () );
1718 /* XXX: need to workaround binutils bug, which exports
1719 * all functions in a dll if no .def file or an empty
1720 * one has been provided... */
1722 //printf ( "%s will have all its functions exported\n",
1723 // module.target->name.c_str () );
1724 fprintf ( fMakefile
,
1725 "\t%s %s%s -o %s %s %s %s\n",
1727 linkerParameters
.c_str (),
1728 linkerScriptArgument
.c_str (),
1729 target_macro
.c_str (),
1730 objectsMacro
.c_str (),
1732 GetLinkerMacro ().c_str () );
1735 GenerateBuildMapCode ();
1736 GenerateBuildNonSymbolStrippedCode ();
1737 GenerateRunRsymCode ();
1738 GenerateRunStripCode ();
1739 GenerateCleanObjectsAsYouGoCode ();
1741 delete definitionFilename
;
1746 MingwModuleHandler::GeneratePhonyTarget() const
1748 string
targetMacro ( GetTargetMacro ( module
) );
1749 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1751 fprintf ( fMakefile
,
1753 targetMacro
.c_str ());
1754 fprintf ( fMakefile
, "%s: | %s\n",
1755 targetMacro
.c_str (),
1756 backend
->GetFullPath ( *target_file
).c_str () );
1762 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1765 string moduleDependencies
;
1767 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1768 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1770 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1771 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1772 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1773 if ( GetExtension ( *objectFilename
) == ".h" )
1774 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1775 else if ( GetExtension ( *objectFilename
) == ".rc" )
1776 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1777 delete objectFilename
;
1780 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1782 GenerateCommands ( *compilationUnits
[i
],
1783 moduleDependencies
);
1784 fprintf ( fMakefile
,
1788 const vector
<If
*>& ifs
= data
.ifs
;
1789 for ( i
= 0; i
< ifs
.size(); i
++ )
1791 GenerateObjectFileTargets ( ifs
[i
]->data
);
1794 vector
<CompilationUnit
*> sourceCompilationUnits
;
1795 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1796 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1798 GenerateCommands ( *sourceCompilationUnits
[i
],
1799 moduleDependencies
);
1801 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1805 MingwModuleHandler::GenerateObjectFileTargets ()
1807 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1811 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1812 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1814 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1815 CLEAN_FILE ( *pchFilename
);
1816 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1817 /* WIDL generated headers may be used */
1818 vector
<FileLocation
> rpcDependencies
;
1819 GetRpcHeaderDependencies ( rpcDependencies
);
1820 if ( rpcDependencies
.size () > 0 )
1821 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1822 fprintf ( fMakefile
,
1824 backend
->GetFullName ( *pchFilename
).c_str(),
1825 dependencies
.c_str(),
1826 backend
->GetFullPath ( *pchFilename
).c_str() );
1827 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1828 fprintf ( fMakefile
,
1829 "\t%s -o %s %s -g %s\n\n",
1830 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1831 backend
->GetFullName ( *pchFilename
).c_str(),
1832 cflagsMacro
.c_str(),
1833 backend
->GetFullName ( baseHeaderFile
).c_str() );
1837 GenerateObjectFileTargets ( module
.non_if_data
);
1838 fprintf ( fMakefile
, "\n" );
1841 /* caller needs to delete the returned object */
1843 MingwModuleHandler::GenerateArchiveTarget ()
1845 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1847 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1849 if ( IsStaticLibrary ( module
) && module
.importLibrary
)
1851 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1853 fprintf ( fMakefile
,
1854 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1855 module
.importLibrary
->dllname
.c_str (),
1856 backend
->GetFullName ( *definitionFilename
).c_str (),
1857 module
.mangledSymbols
? "" : " --kill-at",
1858 module
.underscoreSymbols
? " --add-underscore" : "" );
1860 delete definitionFilename
;
1863 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1865 GenerateCleanObjectsAsYouGoCode ();
1867 fprintf ( fMakefile
, "\n" );
1869 return archiveFilename
;
1873 MingwModuleHandler::GetCFlagsMacro () const
1875 return ssprintf ( "$(%s_CFLAGS)",
1876 module
.name
.c_str () );
1880 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1882 return ssprintf ( "$(%s_OBJS)",
1883 module
.name
.c_str () );
1887 MingwModuleHandler::GetLinkingDependenciesMacro () const
1889 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1893 MingwModuleHandler::GetLibsMacro () const
1895 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1899 MingwModuleHandler::GetLinkerMacro () const
1901 return ssprintf ( "$(%s_LFLAGS)",
1902 module
.name
.c_str () );
1906 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1908 if ( ReferenceObjects ( module
) )
1909 return GetObjectsMacro ( module
);
1912 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1913 string target
= backend
->GetFullName ( *target_file
).c_str ();
1920 MingwModuleHandler::GenerateSourceMacro ()
1922 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1924 GenerateSourceMacros (
1926 module
.non_if_data
);
1928 // future references to the macro will be to get its values
1929 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1933 MingwModuleHandler::GenerateObjectMacro ()
1935 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1937 GenerateObjectMacros (
1939 module
.non_if_data
);
1941 // future references to the macro will be to get its values
1942 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1946 MingwModuleHandler::GenerateTargetMacro ()
1948 fprintf ( fMakefile
,
1950 GetTargetMacro ( module
, false ).c_str (),
1951 GetModuleTargets ( module
).c_str () );
1955 MingwModuleHandler::GetRpcHeaderDependencies (
1956 vector
<FileLocation
>& dependencies
) const
1958 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1960 Library
& library
= *module
.non_if_data
.libraries
[i
];
1961 if ( library
.importedModule
->type
== RpcServer
||
1962 library
.importedModule
->type
== RpcClient
||
1963 library
.importedModule
->type
== RpcProxy
||
1964 library
.importedModule
->type
== IdlHeader
)
1966 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1968 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1969 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1970 string extension
= GetExtension ( sourceFile
);
1971 if ( extension
== ".idl" || extension
== ".IDL" )
1973 string basename
= GetBasename ( sourceFile
.name
);
1974 if ( library
.importedModule
->type
== RpcServer
)
1976 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1977 dependencies
.push_back ( *header
);
1980 if ( library
.importedModule
->type
== RpcClient
)
1982 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1983 dependencies
.push_back ( *header
);
1986 if ( library
.importedModule
->type
== RpcProxy
)
1988 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1989 dependencies
.push_back ( *header
);
1992 if ( library
.importedModule
->type
== IdlHeader
)
1994 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1995 dependencies
.push_back ( *header
);
2005 MingwModuleHandler::GenerateOtherMacros ()
2007 set
<const Define
*> used_defs
;
2009 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
2010 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
2011 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
2012 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
2013 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
2014 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
2015 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
2020 &module
.linkerFlags
,
2023 if ( module
.host
== HostFalse
)
2027 module
.project
.non_if_data
,
2032 vector
<FileLocation
> s
;
2033 if ( module
.importLibrary
)
2035 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2036 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2038 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2039 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2040 string extension
= GetExtension ( sourceFile
);
2041 if ( extension
== ".spec" || extension
== ".SPEC" )
2042 GetSpecObjectDependencies ( s
, &sourceFile
);
2045 if ( s
.size () > 0 )
2050 linkDepsMacro
.c_str() );
2051 for ( size_t i
= 0; i
< s
.size(); i
++ )
2052 fprintf ( fMakefile
,
2054 backend
->GetFullName ( s
[i
] ).c_str () );
2055 fprintf ( fMakefile
, "\n" );
2058 string globalCflags
= "";
2059 if ( module
.host
== HostFalse
)
2060 globalCflags
+= " $(PROJECT_CFLAGS)";
2062 globalCflags
+= " -Wall -Wpointer-arith -D__REACTOS__";
2063 globalCflags
+= " -g";
2064 if ( backend
->usePipe
)
2065 globalCflags
+= " -pipe";
2066 if ( !module
.allowWarnings
)
2067 globalCflags
+= " -Werror";
2068 if ( module
.host
== HostTrue
)
2070 if ( module
.cplusplus
)
2071 globalCflags
+= " $(HOST_CPPFLAGS)";
2073 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
2077 if ( module
.cplusplus
)
2079 // HACK: use host headers when building C++
2080 globalCflags
+= " $(HOST_CPPFLAGS)";
2083 globalCflags
+= " -nostdinc";
2086 // Always force disabling of sibling calls optimisation for GCC
2087 // (TODO: Move to version-specific once this bug is fixed in GCC)
2088 globalCflags
+= " -fno-optimize-sibling-calls";
2093 cflagsMacro
.c_str (),
2094 globalCflags
.c_str () );
2096 if ( module
.host
== HostFalse
)
2100 "%s += $(PROJECT_RCFLAGS)\n",
2101 windresflagsMacro
.c_str () );
2105 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
2106 widlflagsMacro
.c_str (),
2107 module
.output
->relative_path
.c_str () );
2111 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
2112 module
.name
.c_str () );
2118 "%s_LFLAGS += $(HOST_LFLAGS)\n",
2119 module
.name
.c_str () );
2125 linkDepsMacro
.c_str (),
2126 libsMacro
.c_str () );
2128 string cflags
= TypeSpecificCFlags();
2129 if ( cflags
.size() > 0 )
2131 fprintf ( fMakefile
,
2133 cflagsMacro
.c_str (),
2137 string nasmflags
= TypeSpecificNasmFlags();
2138 if ( nasmflags
.size () > 0 )
2140 fprintf ( fMakefile
,
2142 nasmflagsMacro
.c_str (),
2143 nasmflags
.c_str () );
2146 string linkerflags
= TypeSpecificLinkerFlags();
2147 if ( linkerflags
.size() > 0 )
2149 fprintf ( fMakefile
,
2151 linkerflagsMacro
.c_str (),
2152 linkerflags
.c_str () );
2155 if ( IsStaticLibrary ( module
) && module
.isStartupLib
)
2157 fprintf ( fMakefile
,
2158 "%s += -Wno-main\n\n",
2159 cflagsMacro
.c_str () );
2162 fprintf ( fMakefile
, "\n\n" );
2164 // future references to the macros will be to get their values
2165 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2166 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2167 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2171 MingwModuleHandler::GenerateRules ()
2173 string targetMacro
= GetTargetMacro ( module
);
2174 //CLEAN_FILE ( targetMacro );
2175 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2177 // generate phony target for module name
2178 fprintf ( fMakefile
, ".PHONY: %s\n",
2179 module
.name
.c_str () );
2180 string dependencies
= GetTargetMacro ( module
);
2181 if ( module
.type
== Test
)
2182 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2183 fprintf ( fMakefile
, "%s: %s\n\n",
2184 module
.name
.c_str (),
2185 dependencies
.c_str () );
2186 if ( module
.type
== Test
)
2188 fprintf ( fMakefile
,
2190 targetMacro
.c_str ());
2193 if ( !ReferenceObjects ( module
) )
2195 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2199 GenerateObjectFileTargets ();
2203 MingwModuleHandler::GetInvocationDependencies (
2204 const Module
& module
,
2205 string_list
& dependencies
)
2207 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2209 Invoke
& invoke
= *module
.invocations
[i
];
2210 if ( invoke
.invokeModule
== &module
)
2211 /* Protect against circular dependencies */
2213 invoke
.GetTargets ( dependencies
);
2218 MingwModuleHandler::GenerateInvocations () const
2220 if ( module
.invocations
.size () == 0 )
2223 size_t iend
= module
.invocations
.size ();
2224 for ( size_t i
= 0; i
< iend
; i
++ )
2226 const Invoke
& invoke
= *module
.invocations
[i
];
2228 if ( invoke
.invokeModule
->type
!= BuildTool
)
2230 throw XMLInvalidBuildFileException (
2231 module
.node
.location
,
2232 "Only modules of type buildtool can be invoked." );
2235 string invokeTarget
= module
.GetInvocationTarget ( i
);
2236 string_list invoke_targets
;
2237 assert ( invoke_targets
.size() );
2238 invoke
.GetTargets ( invoke_targets
);
2239 fprintf ( fMakefile
,
2241 invokeTarget
.c_str () );
2242 fprintf ( fMakefile
,
2244 invokeTarget
.c_str () );
2245 size_t j
, jend
= invoke_targets
.size();
2246 for ( j
= 0; j
< jend
; j
++ )
2248 fprintf ( fMakefile
,
2250 invoke_targets
[i
].c_str () );
2252 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2253 for ( j
= 1; j
< jend
; j
++ )
2254 fprintf ( fMakefile
,
2256 invoke_targets
[i
].c_str () );
2257 fprintf ( fMakefile
,
2259 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2260 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2261 fprintf ( fMakefile
,
2263 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2264 invoke
.GetParameters ().c_str () );
2269 MingwModuleHandler::GetPreconditionDependenciesName () const
2271 return module
.name
+ "_precondition";
2275 MingwModuleHandler::GetDefaultDependencies (
2276 string_list
& dependencies
) const
2278 /* Avoid circular dependency */
2279 if ( module
.host
== HostTrue
)
2282 dependencies
.push_back ( "$(INIT)" );
2283 if ( module
.name
!= "psdk" )
2284 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2286 /* Check if any dependent library relies on the generated headers */
2287 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2289 const Module
& m
= *module
.project
.modules
[i
];
2290 for ( size_t j
= 0; j
< m
.non_if_data
.compilationUnits
.size (); j
++ )
2292 CompilationUnit
& compilationUnit
= *m
.non_if_data
.compilationUnits
[j
];
2293 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2294 string extension
= GetExtension ( sourceFile
);
2295 if (extension
== ".mc" || extension
== ".MC" )
2297 string dependency
= ssprintf ( "$(%s_MCHEADERS)", m
.name
.c_str () );
2298 dependencies
.push_back ( dependency
);
2305 MingwModuleHandler::GeneratePreconditionDependencies ()
2307 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2308 vector
<FileLocation
> sourceFilenames
;
2309 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
2310 string_list dependencies
;
2311 GetDefaultDependencies ( dependencies
);
2312 GetModuleDependencies ( dependencies
);
2314 GetInvocationDependencies ( module
, dependencies
);
2316 if ( dependencies
.size() )
2318 fprintf ( fMakefile
,
2320 preconditionDependenciesName
.c_str () );
2321 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2322 fprintf ( fMakefile
,
2324 dependencies
[i
].c_str () );
2325 fprintf ( fMakefile
, "\n\n" );
2328 fprintf ( fMakefile
, "\n" );
2332 MingwModuleHandler::IsWineModule () const
2334 if ( module
.importLibrary
== NULL
)
2337 size_t index
= module
.importLibrary
->source
->name
.rfind ( ".spec.def" );
2338 return ( index
!= string::npos
);
2341 /* caller needs to delete the returned object */
2343 MingwModuleHandler::GetDefinitionFilename () const
2345 if ( module
.importLibrary
!= NULL
)
2347 DirectoryLocation directory
;
2348 if ( IsWineModule () )
2349 directory
= IntermediateDirectory
;
2351 directory
= SourceDirectory
;
2353 return new FileLocation ( directory
,
2354 module
.importLibrary
->source
->relative_path
,
2355 module
.importLibrary
->source
->name
);
2358 return new FileLocation ( SourceDirectory
, "tools" + sSep
+ "rbuild", "empty.def" );
2362 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2364 if ( module
.importLibrary
!= NULL
)
2366 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2367 const FileLocation
*defFilename
= GetDefinitionFilename ();
2369 vector
<FileLocation
> deps
;
2370 GetDefinitionDependencies ( deps
);
2372 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
2374 fprintf ( fMakefile
, "%s: %s",
2375 backend
->GetFullName ( *library_target
).c_str (),
2376 backend
->GetFullName ( *defFilename
).c_str () );
2378 size_t i
, iend
= deps
.size();
2379 for ( i
= 0; i
< iend
; i
++ )
2380 fprintf ( fMakefile
, " %s",
2381 backend
->GetFullName ( deps
[i
] ).c_str () );
2383 fprintf ( fMakefile
, " | %s\n",
2384 backend
->GetFullPath ( *library_target
).c_str () );
2386 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2388 fprintf ( fMakefile
,
2389 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2390 module
.output
->name
.c_str (),
2391 backend
->GetFullName ( *defFilename
).c_str (),
2392 backend
->GetFullName ( *library_target
).c_str (),
2393 module
.mangledSymbols
? "" : " --kill-at",
2394 module
.underscoreSymbols
? " --add-underscore" : "" );
2397 delete library_target
;
2402 MingwModuleHandler::GetSpecObjectDependencies (
2403 vector
<FileLocation
>& dependencies
,
2404 const FileLocation
*file
) const
2406 string basename
= GetBasename ( file
->name
);
2408 FileLocation
defDependency ( IntermediateDirectory
,
2409 file
->relative_path
,
2410 basename
+ ".spec.def" );
2411 dependencies
.push_back ( defDependency
);
2413 FileLocation
stubsDependency ( IntermediateDirectory
,
2414 file
->relative_path
,
2415 basename
+ ".stubs.c" );
2416 dependencies
.push_back ( stubsDependency
);
2420 MingwModuleHandler::GetMcObjectDependencies (
2421 vector
<FileLocation
>& dependencies
,
2422 const FileLocation
*file
) const
2424 string basename
= GetBasename ( file
->name
);
2426 FileLocation
defDependency ( IntermediateDirectory
,
2429 dependencies
.push_back ( defDependency
);
2431 FileLocation
stubsDependency ( IntermediateDirectory
,
2432 file
->relative_path
,
2434 dependencies
.push_back ( stubsDependency
);
2438 MingwModuleHandler::GetWidlObjectDependencies (
2439 vector
<FileLocation
>& dependencies
,
2440 const FileLocation
*file
) const
2442 string basename
= GetBasename ( file
->name
);
2443 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2445 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2446 file
->relative_path
,
2447 basename
+ "_s.c" );
2448 dependencies
.push_back ( serverSourceDependency
);
2449 dependencies
.push_back ( *generatedHeaderFilename
);
2451 delete generatedHeaderFilename
;
2455 MingwModuleHandler::GetDefinitionDependencies (
2456 vector
<FileLocation
>& dependencies
) const
2458 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2459 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2461 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2462 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2463 string extension
= GetExtension ( sourceFile
);
2464 if ( extension
== ".spec" || extension
== ".SPEC" )
2465 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2466 if ( extension
== ".idl" || extension
== ".IDL" )
2468 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2469 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2474 enum DebugSupportType
2481 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2487 case DebugKernelMode
:
2488 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2492 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2499 module
.non_if_data
.libraries
.push_back(pLibrary
);
2502 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2503 : MingwModuleHandler ( module_
)
2508 MingwBuildToolModuleHandler::Process ()
2510 GenerateBuildToolModuleTarget ();
2514 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2516 string
targetMacro ( GetTargetMacro (module
) );
2517 string objectsMacro
= GetObjectsMacro ( module
);
2518 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2519 string libsMacro
= GetLibsMacro ();
2524 if ( module
.cplusplus
)
2525 linker
= "${host_gpp}";
2527 linker
= "${host_gcc}";
2529 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2530 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2531 targetMacro
.c_str (),
2532 objectsMacro
.c_str (),
2533 linkDepsMacro
.c_str (),
2534 backend
->GetFullPath ( *target_file
).c_str () );
2535 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2536 fprintf ( fMakefile
,
2537 "\t%s %s -o $@ %s %s\n\n",
2539 GetLinkerMacro ().c_str (),
2540 objectsMacro
.c_str (),
2541 libsMacro
.c_str () );
2547 MingwKernelModuleHandler::MingwKernelModuleHandler (
2548 const Module
& module_
)
2550 : MingwModuleHandler ( module_
)
2555 MingwKernelModuleHandler::Process ()
2557 GenerateKernelModuleTarget ();
2561 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2563 string
targetMacro ( GetTargetMacro ( module
) );
2564 string workingDirectory
= GetWorkingDirectory ( );
2565 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2567 GenerateImportLibraryTargetIfNeeded ();
2569 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2573 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2575 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s",
2576 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2577 module
.baseaddress
.c_str () );
2579 GenerateLinkerCommand ( dependencies
,
2580 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2585 GeneratePhonyTarget();
2590 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2591 const Module
& module_
)
2593 : MingwModuleHandler ( module_
)
2598 MingwStaticLibraryModuleHandler::Process ()
2600 GenerateStaticLibraryModuleTarget ();
2604 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2610 MingwHostStaticLibraryModuleHandler::MingwHostStaticLibraryModuleHandler (
2611 const Module
& module_
)
2613 : MingwModuleHandler ( module_
)
2618 MingwHostStaticLibraryModuleHandler::Process ()
2620 GenerateHostStaticLibraryModuleTarget ();
2624 MingwHostStaticLibraryModuleHandler::GenerateHostStaticLibraryModuleTarget ()
2630 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2631 const Module
& module_
)
2633 : MingwModuleHandler ( module_
)
2638 MingwObjectLibraryModuleHandler::Process ()
2640 GenerateObjectLibraryModuleTarget ();
2644 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2650 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2651 const Module
& module_
)
2653 : MingwModuleHandler ( module_
)
2657 MingwEmbeddedTypeLibModuleHandler::MingwEmbeddedTypeLibModuleHandler (
2658 const Module
& module_
)
2660 : MingwModuleHandler ( module_
)
2665 MingwEmbeddedTypeLibModuleHandler::Process ()
2672 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2674 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2678 MingwKernelModeDLLModuleHandler::Process ()
2680 GenerateKernelModeDLLModuleTarget ();
2684 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2686 string
targetMacro ( GetTargetMacro ( module
) );
2687 string workingDirectory
= GetWorkingDirectory ( );
2688 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2690 GenerateImportLibraryTargetIfNeeded ();
2692 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2696 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2698 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
2699 module
.GetEntryPoint(true).c_str (),
2700 module
.baseaddress
.c_str () );
2701 GenerateLinkerCommand ( dependencies
,
2707 GeneratePhonyTarget();
2712 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2713 const Module
& module_
)
2715 : MingwModuleHandler ( module_
)
2720 MingwKernelModeDriverModuleHandler::AddImplicitLibraries ( Module
& module
)
2722 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2726 MingwKernelModeDriverModuleHandler::Process ()
2728 GenerateKernelModeDriverModuleTarget ();
2733 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2735 string
targetMacro ( GetTargetMacro (module
) );
2736 string workingDirectory
= GetWorkingDirectory ();
2737 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2739 GenerateImportLibraryTargetIfNeeded ();
2741 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2745 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2747 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
2748 module
.GetEntryPoint(true).c_str (),
2749 module
.baseaddress
.c_str () );
2750 GenerateLinkerCommand ( dependencies
,
2756 GeneratePhonyTarget();
2761 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2762 const Module
& module_
)
2764 : MingwModuleHandler ( module_
)
2769 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2771 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2775 MingwNativeDLLModuleHandler::Process ()
2777 GenerateNativeDLLModuleTarget ();
2781 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2783 string
targetMacro ( GetTargetMacro (module
) );
2784 string workingDirectory
= GetWorkingDirectory ( );
2785 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2787 GenerateImportLibraryTargetIfNeeded ();
2789 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2793 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2795 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -shared",
2796 module
.GetEntryPoint(true).c_str (),
2797 module
.baseaddress
.c_str () );
2798 GenerateLinkerCommand ( dependencies
,
2804 GeneratePhonyTarget();
2809 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2810 const Module
& module_
)
2812 : MingwModuleHandler ( module_
)
2817 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2819 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2823 MingwNativeCUIModuleHandler::Process ()
2825 GenerateNativeCUIModuleTarget ();
2829 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2831 string
targetMacro ( GetTargetMacro (module
) );
2832 string workingDirectory
= GetWorkingDirectory ( );
2833 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2835 GenerateImportLibraryTargetIfNeeded ();
2837 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2841 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2843 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2844 module
.GetEntryPoint(true).c_str (),
2845 module
.baseaddress
.c_str () );
2846 GenerateLinkerCommand ( dependencies
,
2852 GeneratePhonyTarget();
2857 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2858 const Module
& module_
)
2860 : MingwModuleHandler ( module_
)
2864 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2865 const Module
& module_
)
2867 : MingwModuleHandler ( module_
)
2872 LinksToCrt( Module
&module
)
2874 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
2876 Library
& library
= *module
.non_if_data
.libraries
[i
];
2877 if ( library
.name
== "libcntpr" || library
.name
== "crt" )
2884 MingwAddImplicitLibraries( Module
&module
)
2889 if ( module
.type
!= Win32DLL
2890 && module
.type
!= Win32OCX
2891 && module
.type
!= Win32CUI
2892 && module
.type
!= Win32GUI
2893 && module
.type
!= Win32SCR
)
2895 // no implicit libraries
2899 links_to_crt
= LinksToCrt ( module
);
2901 if ( !module
.isDefaultEntryPoint
)
2903 if ( module
.GetEntryPoint(false) == "0" )
2905 if ( !links_to_crt
)
2907 pLibrary
= new Library ( module
, "mingw_common" );
2908 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() , pLibrary
);
2910 pLibrary
= new Library ( module
, "msvcrt" );
2911 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2912 links_to_crt
= true;
2918 if ( module
.IsDLL () )
2920 //pLibrary = new Library ( module, "__mingw_dllmain" );
2921 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2925 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2926 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2929 pLibrary
= new Library ( module
, "mingw_common" );
2930 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() + 1, pLibrary
);
2932 if ( !links_to_crt
)
2934 // always link in msvcrt to get the basic routines
2935 pLibrary
= new Library ( module
, "msvcrt" );
2936 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2941 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2943 MingwAddImplicitLibraries ( module
);
2944 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2948 MingwWin32DLLModuleHandler::Process ()
2950 GenerateWin32DLLModuleTarget ();
2954 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2956 string
targetMacro ( GetTargetMacro (module
) );
2957 string workingDirectory
= GetWorkingDirectory ( );
2958 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2960 GenerateImportLibraryTargetIfNeeded ();
2962 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2966 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2968 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
2969 module
.GetEntryPoint(true).c_str (),
2970 module
.baseaddress
.c_str () );
2971 GenerateLinkerCommand ( dependencies
,
2977 GeneratePhonyTarget();
2983 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2985 MingwAddImplicitLibraries ( module
);
2986 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2990 MingwWin32OCXModuleHandler::Process ()
2992 GenerateWin32OCXModuleTarget ();
2996 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2998 string
targetMacro ( GetTargetMacro (module
) );
2999 string workingDirectory
= GetWorkingDirectory ( );
3000 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3002 GenerateImportLibraryTargetIfNeeded ();
3004 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3008 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3010 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
3011 module
.GetEntryPoint(true).c_str (),
3012 module
.baseaddress
.c_str () );
3013 GenerateLinkerCommand ( dependencies
,
3019 GeneratePhonyTarget();
3024 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
3025 const Module
& module_
)
3027 : MingwModuleHandler ( module_
)
3032 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3034 MingwAddImplicitLibraries ( module
);
3035 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3039 MingwWin32CUIModuleHandler::Process ()
3041 GenerateWin32CUIModuleTarget ();
3045 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
3047 string
targetMacro ( GetTargetMacro (module
) );
3048 string workingDirectory
= GetWorkingDirectory ( );
3049 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3051 GenerateImportLibraryTargetIfNeeded ();
3053 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3057 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3059 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3060 module
.GetEntryPoint(true).c_str (),
3061 module
.baseaddress
.c_str () );
3062 GenerateLinkerCommand ( dependencies
,
3068 GeneratePhonyTarget();
3073 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
3074 const Module
& module_
)
3076 : MingwModuleHandler ( module_
)
3081 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3083 MingwAddImplicitLibraries ( module
);
3084 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3088 MingwWin32GUIModuleHandler::Process ()
3090 GenerateWin32GUIModuleTarget ();
3094 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
3096 string
targetMacro ( GetTargetMacro (module
) );
3097 string workingDirectory
= GetWorkingDirectory ( );
3098 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3100 GenerateImportLibraryTargetIfNeeded ();
3102 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3106 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3108 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3109 module
.GetEntryPoint(true).c_str (),
3110 module
.baseaddress
.c_str () );
3111 GenerateLinkerCommand ( dependencies
,
3117 GeneratePhonyTarget();
3122 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
3123 const Module
& module_
)
3125 : MingwModuleHandler ( module_
)
3130 MingwBootLoaderModuleHandler::Process ()
3132 GenerateBootLoaderModuleTarget ();
3136 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
3138 string
targetName ( module
.output
->name
);
3139 string
targetMacro ( GetTargetMacro (module
) );
3140 string workingDirectory
= GetWorkingDirectory ();
3141 FileLocation
junk_tmp ( TemporaryDirectory
,
3143 module
.name
+ ".junk.tmp" );
3144 CLEAN_FILE ( junk_tmp
);
3145 string objectsMacro
= GetObjectsMacro ( module
);
3146 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3147 string libsMacro
= GetLibsMacro ();
3151 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3152 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3153 targetMacro
.c_str (),
3154 objectsMacro
.c_str (),
3155 linkDepsMacro
.c_str (),
3156 backend
->GetFullPath ( *target_file
).c_str () );
3158 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
3160 if (Environment::GetArch() == "arm")
3162 fprintf ( fMakefile
,
3163 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
3164 backend
->GetFullName ( junk_tmp
).c_str (),
3165 objectsMacro
.c_str (),
3166 linkDepsMacro
.c_str (),
3167 GetLinkerMacro ().c_str ());
3171 fprintf ( fMakefile
,
3172 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
3173 backend
->GetFullName ( junk_tmp
).c_str (),
3174 objectsMacro
.c_str (),
3175 linkDepsMacro
.c_str (),
3176 GetLinkerMacro ().c_str ());
3178 fprintf ( fMakefile
,
3179 "\t${objcopy} -O binary %s $@\n",
3180 backend
->GetFullName ( junk_tmp
).c_str () );
3181 GenerateBuildMapCode ( &junk_tmp
);
3182 fprintf ( fMakefile
,
3183 "\t-@${rm} %s 2>$(NUL)\n",
3184 backend
->GetFullName ( junk_tmp
).c_str () );
3190 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
3191 const Module
& module_
)
3193 : MingwModuleHandler ( module_
)
3198 MingwBootSectorModuleHandler::Process ()
3200 GenerateBootSectorModuleTarget ();
3204 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
3206 string objectsMacro
= GetObjectsMacro ( module
);
3210 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3211 module
.name
.c_str ());
3212 fprintf ( fMakefile
,
3214 module
.name
.c_str (),
3215 objectsMacro
.c_str () );
3219 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
3220 const Module
& module_
)
3221 : MingwModuleHandler ( module_
)
3226 MingwBootProgramModuleHandler::Process ()
3228 GenerateBootProgramModuleTarget ();
3232 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3234 string
targetName ( module
.output
->name
);
3235 string
targetMacro ( GetTargetMacro (module
) );
3236 string workingDirectory
= GetWorkingDirectory ();
3237 FileLocation
junk_tmp ( TemporaryDirectory
,
3239 module
.name
+ ".junk.tmp" );
3240 FileLocation
junk_elf ( TemporaryDirectory
,
3242 module
.name
+ ".junk.elf" );
3243 FileLocation
junk_cpy ( TemporaryDirectory
,
3245 module
.name
+ ".junk.elf" );
3246 CLEAN_FILE ( junk_tmp
);
3247 CLEAN_FILE ( junk_elf
);
3248 CLEAN_FILE ( junk_cpy
);
3249 string objectsMacro
= GetObjectsMacro ( module
);
3250 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3251 string libsMacro
= GetLibsMacro ();
3252 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3256 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3257 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3258 targetMacro
.c_str (),
3259 objectsMacro
.c_str (),
3260 linkDepsMacro
.c_str (),
3261 payload
->name
.c_str (),
3262 backend
->GetFullPath ( *target_file
).c_str () );
3264 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3266 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3267 module
.buildtype
.c_str (),
3268 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3269 backend
->GetFullName ( junk_cpy
).c_str () );
3271 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3272 module
.buildtype
.c_str (),
3273 backend
->GetFullName ( junk_cpy
).c_str (),
3274 backend
->GetFullName ( junk_tmp
).c_str () );
3276 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3277 module
.buildtype
.c_str (),
3278 linkDepsMacro
.c_str (),
3279 backend
->GetFullName ( junk_tmp
).c_str (),
3280 backend
->GetFullName ( junk_elf
).c_str () );
3282 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3283 module
.buildtype
.c_str (),
3284 backend
->GetFullName ( junk_elf
).c_str (),
3285 backend
->GetFullName ( *module
.output
) .c_str () );
3287 fprintf ( fMakefile
,
3288 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3289 backend
->GetFullName ( junk_tmp
).c_str (),
3290 backend
->GetFullName ( junk_elf
).c_str (),
3291 backend
->GetFullName ( junk_cpy
).c_str () );
3297 MingwIsoModuleHandler::MingwIsoModuleHandler (
3298 const Module
& module_
)
3300 : MingwModuleHandler ( module_
)
3305 MingwIsoModuleHandler::Process ()
3307 GenerateIsoModuleTarget ();
3311 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3312 const string
& bootcdDirectory
)
3314 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3316 const Module
& m
= *module
.project
.modules
[i
];
3319 if ( m
.bootstrap
!= NULL
)
3321 FileLocation
targetFile ( OutputDirectory
,
3322 m
.bootstrap
->base
.length () > 0
3323 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3325 m
.bootstrap
->nameoncd
);
3326 OutputCopyCommand ( *m
.output
, targetFile
);
3332 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3333 const string
& bootcdDirectory
)
3335 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3337 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3338 FileLocation
targetFile ( OutputDirectory
,
3339 cdfile
.target
->relative_path
.length () > 0
3340 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3342 cdfile
.target
->name
);
3343 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3348 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3349 const string
& bootcdDirectory
)
3351 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3353 const Module
& m
= *module
.project
.modules
[i
];
3356 if ( m
.bootstrap
!= NULL
)
3358 FileLocation
targetDirectory ( OutputDirectory
,
3359 m
.bootstrap
->base
.length () > 0
3360 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3363 out
.push_back ( targetDirectory
);
3369 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3370 const string
& bootcdDirectory
)
3372 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3374 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3375 FileLocation
targetDirectory ( OutputDirectory
,
3376 cdfile
.target
->relative_path
.length () > 0
3377 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3380 out
.push_back( targetDirectory
);
3385 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3386 const string
& bootcdDirectory
)
3388 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3389 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3393 MingwIsoModuleHandler::GetBootstrapCdFiles (
3394 vector
<FileLocation
>& out
) const
3396 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3398 const Module
& m
= *module
.project
.modules
[i
];
3401 if ( m
.bootstrap
!= NULL
)
3403 out
.push_back ( *m
.output
);
3409 MingwIsoModuleHandler::GetNonModuleCdFiles (
3410 vector
<FileLocation
>& out
) const
3412 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3414 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3415 out
.push_back ( *cdfile
.source
);
3420 MingwIsoModuleHandler::GetCdFiles (
3421 vector
<FileLocation
>& out
) const
3423 GetBootstrapCdFiles ( out
);
3424 GetNonModuleCdFiles ( out
);
3428 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3430 string bootcdDirectory
= "cd";
3431 FileLocation
bootcd ( OutputDirectory
,
3434 FileLocation
bootcdReactos ( OutputDirectory
,
3435 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3437 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3438 vector
<FileLocation
> vCdDirectories
;
3441 FileLocation
srcunattend ( SourceDirectory
,
3442 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3444 FileLocation
tarunattend ( bootcdReactos
.directory
,
3445 bootcdReactos
.relative_path
,
3447 if (module
.type
== IsoRegTest
)
3448 vSourceFiles
.push_back ( srcunattend
);
3451 const Module
* bootModule
;
3452 bootModule
= module
.project
.LocateModule ( module
.type
== IsoRegTest
3455 const FileLocation
*isoboot
= bootModule
->output
;
3456 vSourceFiles
.push_back ( *isoboot
);
3458 // prepare reactos.dff and reactos.inf
3459 FileLocation
reactosDff ( SourceDirectory
,
3460 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3462 FileLocation
reactosInf ( bootcdReactos
.directory
,
3463 bootcdReactos
.relative_path
,
3465 FileLocation
vgafontsCab( bootcdReactos
.directory
,
3466 bootcdReactos
.relative_path
,
3468 FileLocation
vgafontsDir( SourceDirectory
,
3469 "media" + sSep
+ "vgafonts",
3472 vSourceFiles
.push_back ( reactosDff
);
3476 if (module
.type
== IsoRegTest
)
3477 IsoName
= "ReactOS-RegTest.iso";
3479 IsoName
= "ReactOS.iso";
3482 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3485 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3486 GetCdFiles ( vCdFiles
);
3487 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3488 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3490 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3491 module
.name
.c_str ());
3492 fprintf ( fMakefile
,
3493 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3494 module
.name
.c_str (),
3495 backend
->GetFullName ( *isoboot
).c_str (),
3496 sourceFiles
.c_str (),
3498 cdDirectories
.c_str () );
3499 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3500 fprintf ( fMakefile
,
3501 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s %s\\*.bin\n", // Escape the asterisk for Make
3502 backend
->GetFullName ( vgafontsCab
).c_str (),
3503 backend
->GetFullName ( vgafontsDir
).c_str ());
3504 fprintf ( fMakefile
,
3505 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3506 backend
->GetFullName ( reactosDff
).c_str (),
3507 backend
->GetFullPath ( bootcdReactos
).c_str () );
3508 fprintf ( fMakefile
,
3509 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3510 backend
->GetFullName ( reactosDff
).c_str (),
3511 backend
->GetFullName ( reactosInf
).c_str (),
3512 backend
->GetFullPath ( bootcdReactos
).c_str ());
3513 fprintf ( fMakefile
,
3514 "\t-@${rm} %s 2>$(NUL)\n",
3515 backend
->GetFullName ( reactosInf
).c_str () );
3516 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3517 OutputCdfileCopyCommands ( bootcdDirectory
);
3519 if (module
.type
== IsoRegTest
)
3520 OutputCopyCommand ( srcunattend
, tarunattend
);
3522 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3523 fprintf ( fMakefile
,
3524 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3525 backend
->GetFullName ( *isoboot
).c_str (),
3526 backend
->GetFullPath ( bootcd
).c_str (),
3528 fprintf ( fMakefile
,
3533 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3534 const Module
& module_
)
3536 : MingwModuleHandler ( module_
)
3541 MingwLiveIsoModuleHandler::Process ()
3543 GenerateLiveIsoModuleTarget ();
3547 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3549 FileLocation
dir ( OutputDirectory
,
3552 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3556 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3557 string
& reactosDirectory
)
3559 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3561 const Module
& m
= *module
.project
.modules
[i
];
3566 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3567 FileLocation
destination ( OutputDirectory
,
3568 m
.install
->relative_path
.length () > 0
3569 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3570 : livecdDirectory
+ sSep
+ reactosDirectory
,
3572 OutputCopyCommand ( *aliasedModule
.output
,
3579 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3580 string
& reactosDirectory
)
3582 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3584 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3585 FileLocation
target ( OutputDirectory
,
3586 installfile
.target
->relative_path
.length () > 0
3587 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3588 : livecdDirectory
+ sSep
+ reactosDirectory
,
3589 installfile
.target
->name
);
3590 OutputCopyCommand ( *installfile
.source
, target
);
3595 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3597 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3598 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3599 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3600 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3601 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3602 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3604 FileLocation
livecdIni ( SourceDirectory
,
3605 "boot" + sSep
+ "bootdata",
3607 FileLocation
destination ( OutputDirectory
,
3610 OutputCopyCommand ( livecdIni
,
3615 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3617 FileLocation
freeldr ( OutputDirectory
,
3618 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3620 FileLocation
destination ( OutputDirectory
,
3621 livecdDirectory
+ sSep
+ "loader",
3623 OutputCopyCommand ( freeldr
,
3628 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3630 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3631 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3633 fprintf ( fMakefile
,
3634 "\t$(ECHO_MKHIVE)\n" );
3635 fprintf ( fMakefile
,
3636 "\t$(MKHIVE_TARGET) boot%cbootdata %s boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst.inf\n",
3637 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3638 cSep
, cSep
, cSep
, cSep
);
3642 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3644 string livecdDirectory
= module
.name
;
3645 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3649 const Module
* bootModule
;
3650 bootModule
= module
.project
.LocateModule ( module
.name
== "livecdregtest"
3653 const FileLocation
*isoboot
= bootModule
->output
;
3654 if (module
.name
== "livecdregtest")
3655 IsoName
= "ReactOS-LiveCD-RegTest.iso";
3657 IsoName
= "ReactOS-LiveCD.iso";
3659 string reactosDirectory
= "reactos";
3660 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3661 FileLocation
livecdReactos ( OutputDirectory
,
3662 livecdReactosNoFixup
,
3664 CLEAN_FILE ( livecdReactos
);
3666 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3667 module
.name
.c_str ());
3668 fprintf ( fMakefile
,
3669 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3670 module
.name
.c_str (),
3671 backend
->GetFullName ( *isoboot
) .c_str (),
3672 backend
->GetFullPath ( livecdReactos
).c_str () );
3673 OutputModuleCopyCommands ( livecdDirectory
,
3675 OutputNonModuleCopyCommands ( livecdDirectory
,
3677 OutputProfilesDirectoryCommands ( livecdDirectory
);
3678 OutputLoaderCommands ( livecdDirectory
);
3679 OutputRegistryCommands ( livecdDirectory
);
3680 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3681 fprintf ( fMakefile
,
3682 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3683 backend
->GetFullName( *isoboot
).c_str (),
3684 backend
->GetFullPath ( livecd
).c_str (),
3686 fprintf ( fMakefile
,
3691 MingwTestModuleHandler::MingwTestModuleHandler (
3692 const Module
& module_
)
3694 : MingwModuleHandler ( module_
)
3699 MingwTestModuleHandler::Process ()
3701 GenerateTestModuleTarget ();
3704 /* caller needs to delete the returned object */
3706 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3708 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3709 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3710 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3714 MingwTestModuleHandler::GenerateTestModuleTarget ()
3716 string
targetMacro ( GetTargetMacro ( module
) );
3717 string workingDirectory
= GetWorkingDirectory ( );
3718 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3720 GenerateImportLibraryTargetIfNeeded ();
3722 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3726 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3728 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3729 module
.GetEntryPoint(true).c_str (),
3730 module
.baseaddress
.c_str () );
3731 GenerateLinkerCommand ( dependencies
,
3737 GeneratePhonyTarget();
3742 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
3743 const Module
& module_
)
3745 : MingwModuleHandler ( module_
)
3750 MingwRpcServerModuleHandler::Process ()
3756 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
3757 const Module
& module_
)
3759 : MingwModuleHandler ( module_
)
3764 MingwRpcClientModuleHandler::Process ()
3770 MingwRpcProxyModuleHandler::MingwRpcProxyModuleHandler (
3771 const Module
& module_
)
3773 : MingwModuleHandler ( module_
)
3778 MingwRpcProxyModuleHandler::Process ()
3784 MingwAliasModuleHandler::MingwAliasModuleHandler (
3785 const Module
& module_
)
3787 : MingwModuleHandler ( module_
)
3792 MingwAliasModuleHandler::Process ()
3796 MingwIdlHeaderModuleHandler::MingwIdlHeaderModuleHandler (
3797 const Module
& module_
)
3799 : MingwModuleHandler ( module_
)
3804 MingwIdlHeaderModuleHandler::Process ()
3809 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3810 const Module
& module_
)
3812 : MingwModuleHandler ( module_
)
3817 MingwElfExecutableModuleHandler::Process ()
3819 string
targetName ( module
.output
->name
);
3820 string
targetMacro ( GetTargetMacro (module
) );
3821 string workingDirectory
= GetWorkingDirectory ();
3822 string objectsMacro
= GetObjectsMacro ( module
);
3823 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3824 string libsMacro
= GetLibsMacro ();
3828 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3829 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3830 targetMacro
.c_str (),
3831 objectsMacro
.c_str (),
3832 linkDepsMacro
.c_str (),
3833 backend
->GetFullPath ( *target_file
).c_str () );
3835 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3837 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3838 module
.buildtype
.c_str(),
3839 objectsMacro
.c_str(),
3841 targetMacro
.c_str () );