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
);
248 handler
= new MingwCabinetModuleHandler ( module
);
250 case EmbeddedTypeLib
:
251 handler
= new MingwEmbeddedTypeLibModuleHandler ( module
);
254 handler
= new MingwElfExecutableModuleHandler ( module
);
257 throw UnknownModuleTypeException (
258 module
.node
.location
,
266 MingwModuleHandler::GetWorkingDirectory () const
272 MingwModuleHandler::GetBasename ( const string
& filename
) const
274 size_t index
= filename
.find_last_of ( '.' );
275 if ( index
!= string::npos
)
276 return filename
.substr ( 0, index
);
280 /* caller needs to delete the returned object */
282 MingwModuleHandler::GetActualSourceFilename (
283 const FileLocation
* file
) const
285 string filename
= file
->name
;
287 string extension
= GetExtension ( *file
);
288 if ( extension
== ".spec" || extension
== ".SPEC" )
290 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
);
291 FileLocation
*sourceFile
= new FileLocation (
292 objectFile
->directory
,
293 objectFile
->relative_path
,
294 ReplaceExtension ( objectFile
->name
, ".c" ) );
298 else if ( ( extension
== ".idl" || extension
== ".IDL" ) &&
299 ( module
.type
== RpcServer
|| module
.type
== RpcClient
|| module
.type
== RpcProxy
) )
301 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
);
302 FileLocation
*sourceFile
= new FileLocation (
303 objectFile
->directory
,
304 objectFile
->relative_path
,
305 ReplaceExtension ( objectFile
->name
, ".c" ) );
309 else if ( extension
== ".mc" || extension
== ".MC" )
311 const FileLocation
*objectFile
= GetObjectFilename ( file
, module
);
312 FileLocation
*sourceFile
= new FileLocation (
313 objectFile
->directory
,
314 objectFile
->relative_path
,
315 ReplaceExtension ( objectFile
->name
, ".rc" ) );
320 return new FileLocation ( *file
);
324 MingwModuleHandler::GetExtraDependencies (
325 const FileLocation
*file
) const
327 string extension
= GetExtension ( *file
);
328 if ( extension
== ".idl" || extension
== ".IDL" )
330 const FileLocation
*header
;
331 switch ( module
.type
)
333 case RpcServer
: header
= GetRpcServerHeaderFilename ( file
); break;
334 case RpcClient
: header
= GetRpcClientHeaderFilename ( file
); break;
335 case RpcProxy
: header
= GetRpcProxyHeaderFilename ( file
); break;
336 case IdlHeader
: header
= GetIdlHeaderFilename ( file
); break;
337 default: header
= NULL
; break;
342 string dependencies
= backend
->GetFullName ( *header
);
344 return " " + dependencies
;
351 MingwModuleHandler::GetCompilationUnitDependencies (
352 const CompilationUnit
& compilationUnit
) const
354 if ( compilationUnit
.GetFiles ().size () <= 1 )
356 vector
<string
> sourceFiles
;
357 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
359 const File
& file
= *compilationUnit
.GetFiles ()[i
];
360 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
362 return string ( " " ) + v2s ( sourceFiles
, 10 );
365 /* caller needs to delete the returned object */
367 MingwModuleHandler::GetModuleArchiveFilename () const
369 if ( IsStaticLibrary ( module
) )
370 return GetTargetFilename ( module
, NULL
);
371 return new FileLocation ( IntermediateDirectory
,
372 module
.output
->relative_path
,
373 ReplaceExtension ( module
.name
, ".temp.a" ) );
377 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
379 string extension
= GetExtension ( file
.file
);
380 return ( extension
== ".spec" || extension
== ".SPEC" );
384 MingwModuleHandler::ReferenceObjects (
385 const Module
& module
)
387 if ( module
.type
== ObjectLibrary
)
389 if ( module
.type
== RpcServer
)
391 if ( module
.type
== RpcClient
)
393 if ( module
.type
== RpcProxy
)
395 if ( module
.type
== IdlHeader
)
401 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
402 const FileLocation
& destination
)
407 "\t${cp} %s %s 1>$(NUL)\n",
408 backend
->GetFullName ( source
).c_str (),
409 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
413 MingwModuleHandler::GetImportLibraryDependency (
414 const Module
& importedModule
)
417 if ( ReferenceObjects ( importedModule
) )
419 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
422 dep
= GetTargetMacro ( importedModule
);
423 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
425 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
426 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
427 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
428 if ( GetExtension ( *objectFilename
) == ".h" )
429 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
430 else if ( GetExtension ( *objectFilename
) == ".rc" )
431 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
436 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
437 dep
= backend
->GetFullName ( *library_target
);
438 delete library_target
;
444 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
445 string_list
& targets
)
447 if ( dependencyModule
.invocations
.size () > 0 )
449 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
451 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
452 invoke
.GetTargets ( targets
);
456 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
460 MingwModuleHandler::GetModuleDependencies (
461 string_list
& dependencies
)
463 size_t iend
= module
.dependencies
.size ();
468 for ( size_t i
= 0; i
< iend
; i
++ )
470 const Dependency
& dependency
= *module
.dependencies
[i
];
471 const Module
& dependencyModule
= *dependency
.dependencyModule
;
472 GetTargets ( dependencyModule
,
475 vector
<FileLocation
> v
;
476 GetDefinitionDependencies ( v
);
478 for ( size_t i
= 0; i
< v
.size (); i
++ )
480 const FileLocation
& file
= v
[i
];
481 dependencies
.push_back ( backend
->GetFullName ( file
) );
486 MingwModuleHandler::GetSourceFilenames ( vector
<FileLocation
>& list
,
487 bool includeGeneratedFiles
) const
491 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
492 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
494 if ( includeGeneratedFiles
|| !compilationUnits
[i
]->IsGeneratedFile () )
496 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
497 const FileLocation
* sourceFileLocation
= GetActualSourceFilename ( &compilationName
);
498 list
.push_back ( *sourceFileLocation
);
499 delete sourceFileLocation
;
502 // intentionally make a copy so that we can append more work in
503 // the middle of processing without having to go recursive
504 vector
<If
*> v
= module
.non_if_data
.ifs
;
505 for ( i
= 0; i
< v
.size (); i
++ )
509 // check for sub-ifs to add to list
510 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
511 for ( j
= 0; j
< ifs
.size (); j
++ )
512 v
.push_back ( ifs
[j
] );
513 const vector
<CompilationUnit
*>& compilationUnits
= rIf
.data
.compilationUnits
;
514 for ( j
= 0; j
< compilationUnits
.size (); j
++ )
516 CompilationUnit
& compilationUnit
= *compilationUnits
[j
];
517 if ( includeGeneratedFiles
|| !compilationUnit
.IsGeneratedFile () )
519 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
520 const FileLocation
* sourceFileLocation
= GetActualSourceFilename ( &compilationName
);
521 list
.push_back ( *sourceFileLocation
);
522 delete sourceFileLocation
;
529 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
530 vector
<FileLocation
>& list
) const
532 GetSourceFilenames ( list
, false );
535 /* caller needs to delete the returned object */
537 MingwModuleHandler::GetObjectFilename (
538 const FileLocation
* sourceFile
,
539 const Module
& module
) const
541 DirectoryLocation destination_directory
;
543 string extension
= GetExtension ( *sourceFile
);
545 if ( module
.type
== BootSector
)
546 return new FileLocation ( *module
.output
);
547 else if ( extension
== ".rc" || extension
== ".RC" )
548 newExtension
= "_" + module
.name
+ ".coff";
549 else if ( extension
== ".mc" || extension
== ".MC" )
550 newExtension
= ".rc";
551 else if ( extension
== ".spec" || extension
== ".SPEC" )
552 newExtension
= ".stubs.o";
553 else if ( extension
== ".idl" || extension
== ".IDL" )
555 if ( module
.type
== RpcServer
)
556 newExtension
= "_s.o";
557 else if ( module
.type
== RpcClient
)
558 newExtension
= "_c.o";
559 else if ( module
.type
== RpcProxy
)
560 newExtension
= "_p.o";
565 newExtension
= "_" + module
.name
+ ".o";
567 if ( module
.type
== BootSector
)
568 destination_directory
= OutputDirectory
;
570 destination_directory
= IntermediateDirectory
;
572 const FileLocation
*obj_file
= new FileLocation(
573 destination_directory
,
574 sourceFile
->relative_path
,
575 ReplaceExtension ( sourceFile
->name
, newExtension
) );
576 PassThruCacheDirectory ( obj_file
);
582 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
584 return module
.name
+ "_clean";
588 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
590 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
592 Library
& library
= *module
.non_if_data
.libraries
[i
];
593 if ( library
.importedModule
->type
== ObjectLibrary
)
594 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
599 MingwModuleHandler::GenerateCleanTarget () const
601 if ( module
.type
== Alias
)
605 ".PHONY: %s_clean\n",
606 module
.name
.c_str() );
607 vector
<string
> referencedModuleNames
;
608 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
611 GetModuleCleanTarget ( module
).c_str(),
612 v2s ( referencedModuleNames
, 10 ).c_str () );
613 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
615 if ( ( i
+ 1 ) % 10 == 9 )
616 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
617 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
619 fprintf ( fMakefile
, " 2>$(NUL)\n" );
621 if( ProxyMakefile::GenerateProxyMakefile(module
) )
623 DirectoryLocation root
;
625 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
626 root
= SourceDirectory
;
628 root
= OutputDirectory
;
630 FileLocation
proxyMakefile ( root
,
631 module
.output
->relative_path
,
633 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
634 backend
->GetFullName ( proxyMakefile
).c_str () );
637 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
641 MingwModuleHandler::GenerateInstallTarget () const
643 if ( !module
.install
)
645 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
648 module
.name
.c_str (),
649 backend
->GetFullName ( *module
.install
).c_str () );
653 MingwModuleHandler::GenerateDependsTarget () const
656 ".PHONY: %s_depends\n",
657 module
.name
.c_str() );
659 "%s_depends: $(RBUILD_TARGET)\n",
660 module
.name
.c_str () );
662 "\t$(ECHO_RBUILD)\n" );
664 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
665 module
.name
.c_str () );
669 MingwModuleHandler::GetObjectFilenames ()
671 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
672 if ( compilationUnits
.size () == 0 )
675 string
objectFilenames ( "" );
676 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
678 if ( objectFilenames
.size () > 0 )
679 objectFilenames
+= " ";
680 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
681 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
682 objectFilenames
+= backend
->GetFullName ( *object_file
);
685 return objectFilenames
;
689 MingwModuleHandler::GenerateGccDefineParametersFromVector (
690 const vector
<Define
*>& defines
,
691 set
<string
>& used_defs
)
695 for ( size_t i
= 0; i
< defines
.size (); i
++ )
697 Define
& define
= *defines
[i
];
698 if (used_defs
.find(define
.name
) != used_defs
.end())
700 if (parameters
.length () > 0)
702 if (define
.name
.find('(') != string::npos
)
703 parameters
+= "$(QT)";
705 parameters
+= define
.name
;
706 if (define
.value
.length () > 0)
709 parameters
+= define
.value
;
711 if (define
.name
.find('(') != string::npos
)
712 parameters
+= "$(QT)";
713 used_defs
.insert(used_defs
.begin(),define
.name
);
719 MingwModuleHandler::GenerateGccDefineParameters () const
721 set
<string
> used_defs
;
722 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
, used_defs
);
723 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
, used_defs
);
724 if ( s
.length () > 0 )
733 MingwModuleHandler::ConcatenatePaths (
735 const string
& path2
) const
737 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
739 if ( path1
[path1
.length ()] == cSep
)
740 return path1
+ path2
;
742 return path1
+ cSep
+ path2
;
746 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
748 string parameters
, path_prefix
;
749 for ( size_t i
= 0; i
< includes
.size (); i
++ )
751 Include
& include
= *includes
[i
];
752 if ( parameters
.length () > 0 )
754 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
760 MingwModuleHandler::GenerateGccIncludeParameters () const
762 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
763 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
764 if ( s
.length () > 0 )
773 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
776 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
778 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
779 if ( compilerFlag
.compiler
== type
)
780 parameters
+= " " + compilerFlag
.flag
;
786 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
789 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
791 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
792 if ( parameters
.length () > 0 )
794 parameters
+= linkerFlag
.flag
;
800 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
801 const vector
<Library
*>& libraries
)
803 string
dependencies ( "" );
805 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
807 if ( wrap_count
++ == 5 )
808 dependencies
+= " \\\n\t\t", wrap_count
= 0;
809 else if ( dependencies
.size () > 0 )
811 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
817 MingwModuleHandler::GenerateLinkerParameters () const
819 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
823 MingwModuleHandler::GenerateMacro (
824 const char* assignmentOperation
,
826 const IfableData
& data
,
827 set
<const Define
*> *used_defs
,
828 bool generatingCompilerMacro
)
831 bool generateAssignment
;
833 if ( generatingCompilerMacro
)
834 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0 || data
.compilerFlags
.size () > 0;
836 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
837 if ( generateAssignment
)
842 assignmentOperation
);
845 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
850 backend
->GetFullPath ( *pchFilename
).c_str () );
854 if ( generatingCompilerMacro
)
856 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
857 if ( compilerParameters
.size () > 0 )
862 compilerParameters
.c_str () );
865 for ( i
= 0; i
< data
.includes
.size(); i
++ )
867 const Include
& include
= *data
.includes
[i
];
868 const FileLocation
* includeDirectory
= include
.directory
;
872 backend
->GetFullPath ( *includeDirectory
).c_str() );
874 for ( i
= 0; i
< data
.defines
.size(); i
++ )
876 const Define
& define
= *data
.defines
[i
];
879 set
<const Define
*>::const_iterator last_define
;
880 for (last_define
= used_defs
->begin ();
881 last_define
!= used_defs
->end ();
884 if ( (*last_define
)->name
!= define
.name
)
886 if ( !define
.overridable
)
888 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
890 "Invalid override of define '%s', already defined at %s",
891 define
.name
.c_str (),
892 define
.node
->location
.c_str () );
894 if ( backend
->configuration
.Verbose
)
895 printf("%s: Overriding '%s' already defined at %s\n",
896 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
897 define
.node
->location
.c_str () );
900 if ( last_define
!= used_defs
->end () )
906 define
.name
.c_str() );
907 if (define
.value
.length () > 0)
911 define
.value
.c_str() );
913 used_defs
->insert( used_defs
->begin (), &define
);
915 if ( generateAssignment
)
917 fprintf ( fMakefile
, "\n" );
922 MingwModuleHandler::GenerateMacros (
923 const char* assignmentOperation
,
924 const IfableData
& data
,
925 const vector
<LinkerFlag
*>* linkerFlags
,
926 set
<const Define
*>& used_defs
)
930 GenerateMacro ( assignmentOperation
,
935 GenerateMacro ( assignmentOperation
,
941 if ( linkerFlags
!= NULL
)
943 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
944 if ( linkerParameters
.size () > 0 )
949 linkerflagsMacro
.c_str (),
951 linkerParameters
.c_str() );
955 if ( data
.libraries
.size () > 0 )
957 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
958 if ( deps
.size () > 0 )
969 const vector
<If
*>& ifs
= data
.ifs
;
970 for ( i
= 0; i
< ifs
.size(); i
++ )
973 if ( rIf
.data
.defines
.size()
974 || rIf
.data
.includes
.size()
975 || rIf
.data
.libraries
.size()
976 || rIf
.data
.compilationUnits
.size()
977 || rIf
.data
.compilerFlags
.size()
978 || rIf
.data
.ifs
.size() )
982 "%s (\"$(%s)\",\"%s\")\n",
983 rIf
.negated
? "ifneq" : "ifeq",
984 rIf
.property
.c_str(),
999 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
1001 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
1002 delete compilationUnits
[i
];
1006 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
1011 MingwModuleHandler::GenerateSourceMacros (
1012 const char* assignmentOperation
,
1013 const IfableData
& data
)
1017 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1018 vector
<const FileLocation
*> headers
;
1019 if ( compilationUnits
.size () > 0 )
1024 sourcesMacro
.c_str (),
1025 assignmentOperation
);
1026 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
1028 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1029 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1033 ( i
%10 == 9 ? " \\\n\t" : " " ),
1034 backend
->GetFullName ( compilationName
).c_str () );
1036 fprintf ( fMakefile
, "\n" );
1039 const vector
<If
*>& ifs
= data
.ifs
;
1040 for ( i
= 0; i
< ifs
.size(); i
++ )
1043 if ( rIf
.data
.defines
.size()
1044 || rIf
.data
.includes
.size()
1045 || rIf
.data
.libraries
.size()
1046 || rIf
.data
.compilationUnits
.size()
1047 || rIf
.data
.compilerFlags
.size()
1048 || rIf
.data
.ifs
.size() )
1052 "%s (\"$(%s)\",\"%s\")\n",
1053 rIf
.negated
? "ifneq" : "ifeq",
1054 rIf
.property
.c_str(),
1055 rIf
.value
.c_str() );
1056 GenerateSourceMacros (
1065 vector
<CompilationUnit
*> sourceCompilationUnits
;
1066 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1067 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1069 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1073 sourcesMacro
.c_str(),
1074 backend
->GetFullName ( compilationName
).c_str () );
1076 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1080 MingwModuleHandler::GenerateObjectMacros (
1081 const char* assignmentOperation
,
1082 const IfableData
& data
)
1086 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1087 vector
<const FileLocation
*> headers
;
1088 vector
<const FileLocation
*> mcheaders
;
1089 vector
<const FileLocation
*> mcresources
;
1090 if ( compilationUnits
.size () > 0 )
1092 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1094 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1095 if ( compilationUnit
.IsFirstFile () )
1097 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1098 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1099 fprintf ( fMakefile
,
1101 objectsMacro
.c_str(),
1102 backend
->GetFullName ( *object_file
).c_str (),
1103 objectsMacro
.c_str() );
1110 objectsMacro
.c_str (),
1111 assignmentOperation
);
1112 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
1114 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1115 if ( !compilationUnit
.IsFirstFile () )
1117 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1118 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1119 if ( GetExtension ( *objectFilename
) == ".h" )
1120 headers
.push_back ( objectFilename
);
1121 else if ( GetExtension ( *objectFilename
) == ".rc" )
1123 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
1124 mcheaders
.push_back ( headerFilename
);
1125 mcresources
.push_back ( objectFilename
);
1132 ( i
%10 == 9 ? " \\\n\t" : " " ),
1133 backend
->GetFullName ( *objectFilename
).c_str () );
1134 delete objectFilename
;
1138 fprintf ( fMakefile
, "\n" );
1140 if ( headers
.size () > 0 )
1145 module
.name
.c_str (),
1146 assignmentOperation
);
1147 for ( i
= 0; i
< headers
.size (); i
++ )
1152 ( i
%10 == 9 ? " \\\n\t" : " " ),
1153 backend
->GetFullName ( *headers
[i
] ).c_str () );
1156 fprintf ( fMakefile
, "\n" );
1159 if ( mcheaders
.size () > 0 )
1164 module
.name
.c_str (),
1165 assignmentOperation
);
1166 for ( i
= 0; i
< mcheaders
.size (); i
++ )
1171 ( i
%10 == 9 ? " \\\n\t" : " " ),
1172 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
1173 delete mcheaders
[i
];
1175 fprintf ( fMakefile
, "\n" );
1178 if ( mcresources
.size () > 0 )
1183 module
.name
.c_str (),
1184 assignmentOperation
);
1185 for ( i
= 0; i
< mcresources
.size (); i
++ )
1190 ( i
%10 == 9 ? " \\\n\t" : " " ),
1191 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
1192 delete mcresources
[i
];
1194 fprintf ( fMakefile
, "\n" );
1197 const vector
<If
*>& ifs
= data
.ifs
;
1198 for ( i
= 0; i
< ifs
.size(); i
++ )
1201 if ( rIf
.data
.defines
.size()
1202 || rIf
.data
.includes
.size()
1203 || rIf
.data
.libraries
.size()
1204 || rIf
.data
.compilationUnits
.size()
1205 || rIf
.data
.compilerFlags
.size()
1206 || rIf
.data
.ifs
.size() )
1210 "%s (\"$(%s)\",\"%s\")\n",
1211 rIf
.negated
? "ifneq" : "ifeq",
1212 rIf
.property
.c_str(),
1213 rIf
.value
.c_str() );
1214 GenerateObjectMacros (
1223 vector
<CompilationUnit
*> sourceCompilationUnits
;
1224 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1225 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1227 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1228 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1232 objectsMacro
.c_str(),
1233 backend
->GetFullName ( *object_file
).c_str () );
1236 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1239 /* caller needs to delete the returned object */
1241 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1243 if ( !module
.pch
|| !use_pch
)
1245 return new FileLocation ( IntermediateDirectory
,
1246 module
.pch
->file
->relative_path
,
1247 ReplaceExtension ( module
.pch
->file
->name
, "_" + module
.name
+ ".gch" ) );
1250 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1251 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1252 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1253 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1254 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1256 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1257 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1259 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1260 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1262 "\t${gcc} -x assembler-with-cpp -c $< -o $@ -D__ASM__ $($(module_name)_CFLAGS)\n",
1263 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1264 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1265 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1266 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1268 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1269 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1270 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1271 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1273 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1274 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1275 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1276 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1277 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1279 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1280 "\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"
1281 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1282 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1283 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1284 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1285 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1286 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"
1288 "\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",
1289 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc", "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h", NULL
);
1290 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1291 "\t$(ECHO_WINEBLD)\n"
1292 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source)\n"
1293 "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1294 "\t$(ECHO_WINEBLD)\n"
1295 "\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"
1296 "$(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"
1298 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1299 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1300 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1301 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1302 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1303 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1304 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1306 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1307 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1308 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1309 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1310 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1312 "\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"
1313 "$(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"
1315 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1316 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1317 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1318 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1319 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1320 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1321 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1323 "\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"
1324 "$(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"
1326 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1327 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1328 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1329 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1330 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1331 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1332 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1334 "\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"
1335 "$(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"
1337 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1338 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1339 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1340 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1341 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1342 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1343 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1345 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1346 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1347 Rule
gccRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1349 "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1350 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1351 Rule
gccHostRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1353 "\t${host_gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1354 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1355 Rule
gppRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1357 "\t${gpp} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1358 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1359 Rule
gppHostRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1361 "\t${host_gpp} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
1362 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1363 Rule
emptyRule ( "", NULL
);
1366 MingwModuleHandler::GenerateGccCommand (
1367 const FileLocation
* sourceFile
,
1369 const string
& extraDependencies
)
1371 const FileLocation
*generatedSourceFileName
= GetActualSourceFilename ( sourceFile
);
1372 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1373 string dependencies
= extraDependencies
;
1376 string extension
= GetExtension ( *sourceFile
);
1377 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1378 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1380 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1384 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1388 /* WIDL generated headers may be used */
1389 vector
<FileLocation
> rpcDependencies
;
1390 GetRpcHeaderDependencies ( rpcDependencies
);
1391 if ( rpcDependencies
.size () > 0 )
1392 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1394 rule
->Execute ( fMakefile
, backend
, module
, generatedSourceFileName
, clean_files
, dependencies
, flags
);
1396 delete generatedSourceFileName
;
1400 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1402 for ( size_t i
= 0; i
< module
.project
.non_if_data
.properties
.size (); i
++ )
1404 const Property
& property
= *module
.project
.non_if_data
.properties
[i
];
1405 if ( property
.name
== name
)
1406 return property
.value
;
1408 return string ( "" );
1411 /* caller needs to delete the returned object */
1413 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1415 string newname
= GetBasename ( base
->name
) + "_s.h";
1416 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1419 /* caller needs to delete the returned object */
1421 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1423 string newname
= GetBasename ( base
->name
) + "_c.h";
1424 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1427 /* caller needs to delete the returned object */
1429 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1431 string newname
= GetBasename ( base
->name
) + "_p.h";
1432 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1435 /* caller needs to delete the returned object */
1437 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1439 string newname
= GetBasename ( base
->name
) + ".h";
1440 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1443 /* caller needs to delete the returned object */
1445 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1447 string newname
= GetBasename ( base
->name
) + ".h";
1448 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1452 MingwModuleHandler::GenerateCommands (
1453 const CompilationUnit
& compilationUnit
,
1454 const string
& extraDependencies
)
1456 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1457 string extension
= GetExtension ( sourceFile
);
1458 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1467 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1468 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1469 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1470 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1471 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1472 { HostDontCare
, TypeDontCare
, ".spec", &winebuildRule
},
1473 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1474 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1475 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1476 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1477 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1478 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1479 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1480 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1481 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1482 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1483 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1484 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1485 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1486 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1489 Rule
*customRule
= NULL
;
1491 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1493 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= module
.host
)
1495 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1497 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1499 customRule
= rules
[i
].rule
;
1503 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1505 GenerateGccCommand ( &sourceFile
,
1507 GetCompilationUnitDependencies ( compilationUnit
) + GetExtraDependencies ( &sourceFile
) + extraDependencies
);
1509 else if ( customRule
)
1510 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1513 throw InvalidOperationException ( __FILE__
,
1515 "Unsupported filename extension '%s' in file '%s'",
1517 backend
->GetFullName ( sourceFile
).c_str () );
1522 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1524 fprintf ( fMakefile
,
1525 "ifeq ($(ROS_BUILDMAP),full)\n" );
1527 FileLocation
mapFilename ( OutputDirectory
,
1528 module
.output
->relative_path
,
1529 GetBasename ( module
.output
->name
) + ".map" );
1530 CLEAN_FILE ( mapFilename
);
1532 fprintf ( fMakefile
,
1533 "\t$(ECHO_OBJDUMP)\n" );
1534 fprintf ( fMakefile
,
1535 "\t$(Q)${objdump} -d -S %s > %s\n",
1536 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1537 backend
->GetFullName ( mapFilename
).c_str () );
1539 fprintf ( fMakefile
,
1541 fprintf ( fMakefile
,
1542 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1544 fprintf ( fMakefile
,
1546 fprintf ( fMakefile
,
1547 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1548 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1549 backend
->GetFullName ( mapFilename
).c_str () );
1551 fprintf ( fMakefile
,
1554 fprintf ( fMakefile
,
1559 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1561 fprintf ( fMakefile
,
1562 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1564 FileLocation
nostripFilename ( OutputDirectory
,
1565 module
.output
->relative_path
,
1566 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1567 CLEAN_FILE ( nostripFilename
);
1569 OutputCopyCommand ( *module
.output
, nostripFilename
);
1571 fprintf ( fMakefile
,
1576 MergeStringVector ( const Backend
* backend
,
1577 const vector
<FileLocation
>& input
,
1578 vector
<string
>& output
)
1582 int wrap_count
= -1;
1583 for ( size_t i
= 0; i
< input
.size (); i
++ )
1585 if ( wrap_count
++ == wrap_at
)
1587 output
.push_back ( s
);
1591 else if ( s
.size () > 0)
1593 s
+= backend
->GetFullName ( input
[i
] );
1595 if ( s
.length () > 0 )
1596 output
.push_back ( s
);
1600 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1601 vector
<FileLocation
>& objectFiles
) const
1603 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1605 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1606 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1607 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1608 objectFiles
.push_back ( *object_file
);
1614 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1616 if ( backend
->configuration
.CleanAsYouGo
)
1618 vector
<FileLocation
> objectFiles
;
1619 GetObjectsVector ( module
.non_if_data
,
1621 vector
<string
> lines
;
1622 MergeStringVector ( backend
,
1625 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1627 fprintf ( fMakefile
,
1628 "\t-@${rm} %s 2>$(NUL)\n",
1629 lines
[i
].c_str () );
1635 MingwModuleHandler::GenerateRunRsymCode () const
1637 fprintf ( fMakefile
,
1638 "\t$(ECHO_RSYM)\n" );
1639 fprintf ( fMakefile
,
1640 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1644 MingwModuleHandler::GenerateRunStripCode () const
1646 fprintf ( fMakefile
,
1647 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1648 fprintf ( fMakefile
,
1649 "\t$(ECHO_STRIP)\n" );
1650 fprintf ( fMakefile
,
1651 "\t${strip} -s -x -X $@\n\n" );
1652 fprintf ( fMakefile
,
1657 MingwModuleHandler::GenerateLinkerCommand (
1658 const string
& dependencies
,
1659 const string
& linkerParameters
,
1660 const string
& pefixupParameters
)
1662 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1663 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1664 string linker
= module
.cplusplus
? "${gpp}" : "${gcc}";
1665 string objectsMacro
= GetObjectsMacro ( module
);
1666 string libsMacro
= GetLibsMacro ();
1668 string
target_macro ( GetTargetMacro ( module
) );
1669 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1671 string linkerScriptArgument
;
1672 if ( module
.linkerScript
!= NULL
)
1673 linkerScriptArgument
= ssprintf ( " -Wl,-T,%s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1675 linkerScriptArgument
= "";
1677 fprintf ( fMakefile
,
1678 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1679 target_macro
.c_str (),
1680 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1681 dependencies
.c_str (),
1682 target_folder
.c_str () );
1683 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1684 string
targetName ( module
.output
->name
);
1686 if ( !module
.IsDLL () )
1688 fprintf ( fMakefile
,
1689 "\t%s %s%s -o %s %s %s %s\n",
1691 linkerParameters
.c_str (),
1692 linkerScriptArgument
.c_str (),
1693 target_macro
.c_str (),
1694 objectsMacro
.c_str (),
1696 GetLinkerMacro ().c_str () );
1698 else if ( module
.HasImportLibrary () )
1700 FileLocation
temp_exp ( TemporaryDirectory
,
1702 module
.name
+ ".temp.exp" );
1703 CLEAN_FILE ( temp_exp
);
1705 fprintf ( fMakefile
,
1706 "\t${dlltool} --dllname %s --def %s --output-exp %s%s%s\n",
1707 targetName
.c_str (),
1708 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1709 backend
->GetFullName ( temp_exp
).c_str (),
1710 module
.mangledSymbols
? "" : " --kill-at",
1711 module
.underscoreSymbols
? " --add-underscore" : "" );
1713 fprintf ( fMakefile
,
1714 "\t%s %s%s %s -o %s %s %s %s\n",
1716 linkerParameters
.c_str (),
1717 linkerScriptArgument
.c_str (),
1718 backend
->GetFullName ( temp_exp
).c_str (),
1719 target_macro
.c_str (),
1720 objectsMacro
.c_str (),
1722 GetLinkerMacro ().c_str () );
1724 fprintf ( fMakefile
,
1725 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1726 target_macro
.c_str (),
1727 pefixupParameters
.c_str() );
1729 fprintf ( fMakefile
,
1730 "\t-@${rm} %s 2>$(NUL)\n",
1731 backend
->GetFullName ( temp_exp
).c_str () );
1735 /* XXX: need to workaround binutils bug, which exports
1736 * all functions in a dll if no .def file or an empty
1737 * one has been provided... */
1739 //printf ( "%s will have all its functions exported\n",
1740 // module.target->name.c_str () );
1741 fprintf ( fMakefile
,
1742 "\t%s %s%s -o %s %s %s %s\n",
1744 linkerParameters
.c_str (),
1745 linkerScriptArgument
.c_str (),
1746 target_macro
.c_str (),
1747 objectsMacro
.c_str (),
1749 GetLinkerMacro ().c_str () );
1752 GenerateBuildMapCode ();
1753 GenerateBuildNonSymbolStrippedCode ();
1754 GenerateRunRsymCode ();
1755 GenerateRunStripCode ();
1756 GenerateCleanObjectsAsYouGoCode ();
1758 if ( definitionFilename
)
1759 delete definitionFilename
;
1764 MingwModuleHandler::GeneratePhonyTarget() const
1766 string
targetMacro ( GetTargetMacro ( module
) );
1767 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1769 fprintf ( fMakefile
,
1771 targetMacro
.c_str ());
1772 fprintf ( fMakefile
, "%s: | %s\n",
1773 targetMacro
.c_str (),
1774 backend
->GetFullPath ( *target_file
).c_str () );
1780 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1783 string moduleDependencies
;
1785 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1786 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1788 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1789 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1790 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1791 if ( GetExtension ( *objectFilename
) == ".h" )
1792 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1793 else if ( GetExtension ( *objectFilename
) == ".rc" )
1794 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1795 delete objectFilename
;
1798 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1800 GenerateCommands ( *compilationUnits
[i
],
1801 moduleDependencies
);
1802 fprintf ( fMakefile
,
1806 const vector
<If
*>& ifs
= data
.ifs
;
1807 for ( i
= 0; i
< ifs
.size(); i
++ )
1809 GenerateObjectFileTargets ( ifs
[i
]->data
);
1812 vector
<CompilationUnit
*> sourceCompilationUnits
;
1813 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1814 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1816 GenerateCommands ( *sourceCompilationUnits
[i
],
1817 moduleDependencies
);
1819 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1823 MingwModuleHandler::GenerateObjectFileTargets ()
1825 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1829 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1830 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1832 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1833 CLEAN_FILE ( *pchFilename
);
1834 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1835 /* WIDL generated headers may be used */
1836 vector
<FileLocation
> rpcDependencies
;
1837 GetRpcHeaderDependencies ( rpcDependencies
);
1838 if ( rpcDependencies
.size () > 0 )
1839 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1840 fprintf ( fMakefile
,
1841 "%s: %s ${%s_precondition} | %s\n",
1842 backend
->GetFullName ( *pchFilename
).c_str(),
1843 dependencies
.c_str(),
1844 module
.name
.c_str (),
1845 backend
->GetFullPath ( *pchFilename
).c_str() );
1846 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1847 fprintf ( fMakefile
,
1848 "\t%s -o %s %s -g %s\n\n",
1849 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1850 backend
->GetFullName ( *pchFilename
).c_str(),
1851 cflagsMacro
.c_str(),
1852 backend
->GetFullName ( baseHeaderFile
).c_str() );
1856 GenerateObjectFileTargets ( module
.non_if_data
);
1857 fprintf ( fMakefile
, "\n" );
1860 /* caller needs to delete the returned object */
1862 MingwModuleHandler::GenerateArchiveTarget ()
1864 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1865 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1867 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1869 if ( IsStaticLibrary ( module
) && definitionFilename
)
1871 fprintf ( fMakefile
,
1872 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1873 module
.importLibrary
->dllname
.c_str (),
1874 backend
->GetFullName ( *definitionFilename
).c_str (),
1875 module
.mangledSymbols
? "" : " --kill-at",
1876 module
.underscoreSymbols
? " --add-underscore" : "" );
1879 if ( definitionFilename
)
1880 delete definitionFilename
;
1882 if(module
.type
== HostStaticLibrary
)
1883 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1885 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1887 GenerateCleanObjectsAsYouGoCode ();
1889 fprintf ( fMakefile
, "\n" );
1891 return archiveFilename
;
1895 MingwModuleHandler::GetCFlagsMacro () const
1897 return ssprintf ( "$(%s_CFLAGS)",
1898 module
.name
.c_str () );
1902 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1904 return ssprintf ( "$(%s_OBJS)",
1905 module
.name
.c_str () );
1909 MingwModuleHandler::GetLinkingDependenciesMacro () const
1911 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1915 MingwModuleHandler::GetLibsMacro () const
1917 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1921 MingwModuleHandler::GetLinkerMacro () const
1923 return ssprintf ( "$(%s_LFLAGS)",
1924 module
.name
.c_str () );
1928 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1930 if ( ReferenceObjects ( module
) )
1931 return GetObjectsMacro ( module
);
1934 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1935 string target
= backend
->GetFullName ( *target_file
).c_str ();
1942 MingwModuleHandler::GenerateSourceMacro ()
1944 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1946 GenerateSourceMacros (
1948 module
.non_if_data
);
1950 // future references to the macro will be to get its values
1951 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1955 MingwModuleHandler::GenerateObjectMacro ()
1957 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1959 GenerateObjectMacros (
1961 module
.non_if_data
);
1963 // future references to the macro will be to get its values
1964 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1968 MingwModuleHandler::GenerateTargetMacro ()
1970 fprintf ( fMakefile
,
1972 GetTargetMacro ( module
, false ).c_str (),
1973 GetModuleTargets ( module
).c_str () );
1977 MingwModuleHandler::GetRpcHeaderDependencies (
1978 vector
<FileLocation
>& dependencies
) const
1980 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1982 Library
& library
= *module
.non_if_data
.libraries
[i
];
1983 if ( library
.importedModule
->type
== RpcServer
||
1984 library
.importedModule
->type
== RpcClient
||
1985 library
.importedModule
->type
== RpcProxy
||
1986 library
.importedModule
->type
== IdlHeader
)
1988 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1990 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1991 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1992 string extension
= GetExtension ( sourceFile
);
1993 if ( extension
== ".idl" || extension
== ".IDL" )
1995 string basename
= GetBasename ( sourceFile
.name
);
1996 if ( library
.importedModule
->type
== RpcServer
)
1998 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1999 dependencies
.push_back ( *header
);
2002 if ( library
.importedModule
->type
== RpcClient
)
2004 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
2005 dependencies
.push_back ( *header
);
2008 if ( library
.importedModule
->type
== RpcProxy
)
2010 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
2011 dependencies
.push_back ( *header
);
2014 if ( library
.importedModule
->type
== IdlHeader
)
2016 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
2017 dependencies
.push_back ( *header
);
2027 MingwModuleHandler::GenerateOtherMacros ()
2029 set
<const Define
*> used_defs
;
2031 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
2032 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
2033 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
2034 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
2035 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
2036 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
2037 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
2042 &module
.linkerFlags
,
2045 if ( module
.host
== HostFalse
)
2049 module
.project
.non_if_data
,
2054 vector
<FileLocation
> s
;
2055 if ( module
.importLibrary
)
2057 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2058 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2060 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2061 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2062 string extension
= GetExtension ( sourceFile
);
2063 if ( extension
== ".spec" || extension
== ".SPEC" )
2064 GetSpecObjectDependencies ( s
, &sourceFile
);
2067 if ( s
.size () > 0 )
2072 linkDepsMacro
.c_str() );
2073 for ( size_t i
= 0; i
< s
.size(); i
++ )
2074 fprintf ( fMakefile
,
2076 backend
->GetFullName ( s
[i
] ).c_str () );
2077 fprintf ( fMakefile
, "\n" );
2080 string globalCflags
= "";
2081 if ( module
.host
== HostFalse
)
2082 globalCflags
+= " $(PROJECT_CFLAGS)";
2084 globalCflags
+= " -Wall -Wpointer-arith -D__REACTOS__";
2085 globalCflags
+= " -g";
2086 if ( backend
->usePipe
)
2087 globalCflags
+= " -pipe";
2088 if ( !module
.allowWarnings
)
2089 globalCflags
+= " -Werror";
2090 if ( module
.host
== HostTrue
)
2092 if ( module
.cplusplus
)
2093 globalCflags
+= " $(HOST_CPPFLAGS)";
2095 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
2099 if ( module
.cplusplus
)
2101 // HACK: use host headers when building C++
2102 globalCflags
+= " $(HOST_CPPFLAGS)";
2105 globalCflags
+= " -nostdinc";
2108 // Always force disabling of sibling calls optimisation for GCC
2109 // (TODO: Move to version-specific once this bug is fixed in GCC)
2110 globalCflags
+= " -fno-optimize-sibling-calls";
2115 cflagsMacro
.c_str (),
2116 globalCflags
.c_str () );
2118 if ( module
.host
== HostFalse
)
2122 "%s += $(PROJECT_RCFLAGS)\n",
2123 windresflagsMacro
.c_str () );
2127 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
2128 widlflagsMacro
.c_str (),
2129 module
.output
->relative_path
.c_str () );
2133 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
2134 module
.name
.c_str () );
2140 "%s_LFLAGS += $(HOST_LFLAGS)\n",
2141 module
.name
.c_str () );
2147 linkDepsMacro
.c_str (),
2148 libsMacro
.c_str () );
2150 string cflags
= TypeSpecificCFlags();
2151 if ( cflags
.size() > 0 )
2153 fprintf ( fMakefile
,
2155 cflagsMacro
.c_str (),
2159 string nasmflags
= TypeSpecificNasmFlags();
2160 if ( nasmflags
.size () > 0 )
2162 fprintf ( fMakefile
,
2164 nasmflagsMacro
.c_str (),
2165 nasmflags
.c_str () );
2168 string linkerflags
= TypeSpecificLinkerFlags();
2169 if ( linkerflags
.size() > 0 )
2171 fprintf ( fMakefile
,
2173 linkerflagsMacro
.c_str (),
2174 linkerflags
.c_str () );
2177 if ( IsStaticLibrary ( module
) && module
.isStartupLib
)
2179 fprintf ( fMakefile
,
2180 "%s += -Wno-main\n\n",
2181 cflagsMacro
.c_str () );
2184 fprintf ( fMakefile
, "\n\n" );
2186 // future references to the macros will be to get their values
2187 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2188 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2189 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2193 MingwModuleHandler::GenerateRules ()
2195 string targetMacro
= GetTargetMacro ( module
);
2196 //CLEAN_FILE ( targetMacro );
2197 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2199 // generate phony target for module name
2200 fprintf ( fMakefile
, ".PHONY: %s\n",
2201 module
.name
.c_str () );
2202 string dependencies
= GetTargetMacro ( module
);
2203 if ( module
.type
== Test
)
2204 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2205 fprintf ( fMakefile
, "%s: %s\n\n",
2206 module
.name
.c_str (),
2207 dependencies
.c_str () );
2208 if ( module
.type
== Test
)
2210 fprintf ( fMakefile
,
2212 targetMacro
.c_str ());
2215 if ( !ReferenceObjects ( module
) )
2217 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2221 GenerateObjectFileTargets ();
2225 MingwModuleHandler::GetInvocationDependencies (
2226 const Module
& module
,
2227 string_list
& dependencies
)
2229 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2231 Invoke
& invoke
= *module
.invocations
[i
];
2232 if ( invoke
.invokeModule
== &module
)
2233 /* Protect against circular dependencies */
2235 invoke
.GetTargets ( dependencies
);
2240 MingwModuleHandler::GenerateInvocations () const
2242 if ( module
.invocations
.size () == 0 )
2245 size_t iend
= module
.invocations
.size ();
2246 for ( size_t i
= 0; i
< iend
; i
++ )
2248 const Invoke
& invoke
= *module
.invocations
[i
];
2250 if ( invoke
.invokeModule
->type
!= BuildTool
)
2252 throw XMLInvalidBuildFileException (
2253 module
.node
.location
,
2254 "Only modules of type buildtool can be invoked." );
2257 string invokeTarget
= module
.GetInvocationTarget ( i
);
2258 string_list invoke_targets
;
2259 assert ( invoke_targets
.size() );
2260 invoke
.GetTargets ( invoke_targets
);
2261 fprintf ( fMakefile
,
2263 invokeTarget
.c_str () );
2264 fprintf ( fMakefile
,
2266 invokeTarget
.c_str () );
2267 size_t j
, jend
= invoke_targets
.size();
2268 for ( j
= 0; j
< jend
; j
++ )
2270 fprintf ( fMakefile
,
2272 invoke_targets
[i
].c_str () );
2274 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2275 for ( j
= 1; j
< jend
; j
++ )
2276 fprintf ( fMakefile
,
2278 invoke_targets
[i
].c_str () );
2279 fprintf ( fMakefile
,
2281 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2282 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2283 fprintf ( fMakefile
,
2285 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2286 invoke
.GetParameters ().c_str () );
2291 MingwModuleHandler::GetPreconditionDependenciesName () const
2293 return module
.name
+ "_precondition";
2297 MingwModuleHandler::GetDefaultDependencies (
2298 string_list
& dependencies
) const
2300 /* Avoid circular dependency */
2301 if ( module
.host
== HostTrue
)
2304 if ( module
.name
!= "psdk" )
2305 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2307 /* Check if any dependent library relies on the generated headers */
2308 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2310 const Module
& m
= *module
.project
.modules
[i
];
2311 for ( size_t j
= 0; j
< m
.non_if_data
.compilationUnits
.size (); j
++ )
2313 CompilationUnit
& compilationUnit
= *m
.non_if_data
.compilationUnits
[j
];
2314 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2315 string extension
= GetExtension ( sourceFile
);
2316 if (extension
== ".mc" || extension
== ".MC" )
2318 string dependency
= ssprintf ( "$(%s_MCHEADERS)", m
.name
.c_str () );
2319 dependencies
.push_back ( dependency
);
2326 MingwModuleHandler::GeneratePreconditionDependencies ()
2328 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2329 vector
<FileLocation
> sourceFilenames
;
2330 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
2331 string_list dependencies
;
2332 GetDefaultDependencies ( dependencies
);
2333 GetModuleDependencies ( dependencies
);
2335 GetInvocationDependencies ( module
, dependencies
);
2337 if ( dependencies
.size() )
2339 fprintf ( fMakefile
,
2341 preconditionDependenciesName
.c_str () );
2342 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2343 fprintf ( fMakefile
,
2345 dependencies
[i
].c_str () );
2346 fprintf ( fMakefile
, "\n\n" );
2349 fprintf ( fMakefile
, "\n" );
2353 MingwModuleHandler::IsWineModule () const
2355 if ( module
.importLibrary
== NULL
)
2358 size_t index
= module
.importLibrary
->source
->name
.rfind ( ".spec.def" );
2359 return ( index
!= string::npos
);
2362 /* caller needs to delete the returned object */
2364 MingwModuleHandler::GetDefinitionFilename () const
2366 if ( module
.importLibrary
== NULL
)
2369 DirectoryLocation directory
;
2370 if ( IsWineModule () )
2371 directory
= IntermediateDirectory
;
2373 directory
= SourceDirectory
;
2375 return new FileLocation ( directory
,
2376 module
.importLibrary
->source
->relative_path
,
2377 module
.importLibrary
->source
->name
);
2381 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2383 if ( module
.importLibrary
!= NULL
)
2385 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2386 const FileLocation
*defFilename
= GetDefinitionFilename ();
2387 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2389 vector
<FileLocation
> deps
;
2390 GetDefinitionDependencies ( deps
);
2392 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
2394 fprintf ( fMakefile
, "%s:",
2395 backend
->GetFullName ( *library_target
).c_str () );
2399 fprintf ( fMakefile
, " %s",
2400 backend
->GetFullName ( *defFilename
).c_str () );
2403 size_t i
, iend
= deps
.size();
2404 for ( i
= 0; i
< iend
; i
++ )
2405 fprintf ( fMakefile
, " %s",
2406 backend
->GetFullName ( deps
[i
] ).c_str () );
2408 fprintf ( fMakefile
, " | %s\n",
2409 backend
->GetFullPath ( *library_target
).c_str () );
2411 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2413 fprintf ( fMakefile
,
2414 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2415 module
.output
->name
.c_str (),
2416 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2418 backend
->GetFullName ( *library_target
).c_str (),
2419 module
.mangledSymbols
? "" : " --kill-at",
2420 module
.underscoreSymbols
? " --add-underscore" : "" );
2424 delete library_target
;
2429 MingwModuleHandler::GetSpecObjectDependencies (
2430 vector
<FileLocation
>& dependencies
,
2431 const FileLocation
*file
) const
2433 string basename
= GetBasename ( file
->name
);
2435 FileLocation
defDependency ( IntermediateDirectory
,
2436 file
->relative_path
,
2437 basename
+ ".spec.def" );
2438 dependencies
.push_back ( defDependency
);
2440 FileLocation
stubsDependency ( IntermediateDirectory
,
2441 file
->relative_path
,
2442 basename
+ ".stubs.c" );
2443 dependencies
.push_back ( stubsDependency
);
2447 MingwModuleHandler::GetMcObjectDependencies (
2448 vector
<FileLocation
>& dependencies
,
2449 const FileLocation
*file
) const
2451 string basename
= GetBasename ( file
->name
);
2453 FileLocation
defDependency ( IntermediateDirectory
,
2456 dependencies
.push_back ( defDependency
);
2458 FileLocation
stubsDependency ( IntermediateDirectory
,
2459 file
->relative_path
,
2461 dependencies
.push_back ( stubsDependency
);
2465 MingwModuleHandler::GetWidlObjectDependencies (
2466 vector
<FileLocation
>& dependencies
,
2467 const FileLocation
*file
) const
2469 string basename
= GetBasename ( file
->name
);
2470 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2472 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2473 file
->relative_path
,
2474 basename
+ "_s.c" );
2475 dependencies
.push_back ( serverSourceDependency
);
2476 dependencies
.push_back ( *generatedHeaderFilename
);
2478 delete generatedHeaderFilename
;
2482 MingwModuleHandler::GetDefinitionDependencies (
2483 vector
<FileLocation
>& dependencies
) const
2485 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2486 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2488 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2489 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2490 string extension
= GetExtension ( sourceFile
);
2491 if ( extension
== ".spec" || extension
== ".SPEC" )
2492 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2493 if ( extension
== ".idl" || extension
== ".IDL" )
2495 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2496 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2501 enum DebugSupportType
2508 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2514 case DebugKernelMode
:
2515 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2519 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2526 module
.non_if_data
.libraries
.push_back(pLibrary
);
2529 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2530 : MingwModuleHandler ( module_
)
2535 MingwBuildToolModuleHandler::Process ()
2537 GenerateBuildToolModuleTarget ();
2541 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2543 string
targetMacro ( GetTargetMacro (module
) );
2544 string objectsMacro
= GetObjectsMacro ( module
);
2545 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2546 string libsMacro
= GetLibsMacro ();
2551 if ( module
.cplusplus
)
2552 linker
= "${host_gpp}";
2554 linker
= "${host_gcc}";
2556 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2557 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2558 targetMacro
.c_str (),
2559 objectsMacro
.c_str (),
2560 linkDepsMacro
.c_str (),
2561 backend
->GetFullPath ( *target_file
).c_str () );
2562 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2563 fprintf ( fMakefile
,
2564 "\t%s %s -o $@ %s %s\n\n",
2566 GetLinkerMacro ().c_str (),
2567 objectsMacro
.c_str (),
2568 libsMacro
.c_str () );
2574 MingwKernelModuleHandler::MingwKernelModuleHandler (
2575 const Module
& module_
)
2577 : MingwModuleHandler ( module_
)
2582 MingwKernelModuleHandler::Process ()
2584 GenerateKernelModuleTarget ();
2588 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2590 string
targetMacro ( GetTargetMacro ( module
) );
2591 string workingDirectory
= GetWorkingDirectory ( );
2592 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2594 GenerateImportLibraryTargetIfNeeded ();
2596 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2600 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2602 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s",
2603 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2604 module
.baseaddress
.c_str () );
2606 GenerateLinkerCommand ( dependencies
,
2607 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2612 GeneratePhonyTarget();
2617 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2618 const Module
& module_
)
2620 : MingwModuleHandler ( module_
)
2625 MingwStaticLibraryModuleHandler::Process ()
2627 GenerateStaticLibraryModuleTarget ();
2631 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2637 MingwHostStaticLibraryModuleHandler::MingwHostStaticLibraryModuleHandler (
2638 const Module
& module_
)
2640 : MingwModuleHandler ( module_
)
2645 MingwHostStaticLibraryModuleHandler::Process ()
2647 GenerateHostStaticLibraryModuleTarget ();
2651 MingwHostStaticLibraryModuleHandler::GenerateHostStaticLibraryModuleTarget ()
2657 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2658 const Module
& module_
)
2660 : MingwModuleHandler ( module_
)
2665 MingwObjectLibraryModuleHandler::Process ()
2667 GenerateObjectLibraryModuleTarget ();
2671 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2677 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2678 const Module
& module_
)
2680 : MingwModuleHandler ( module_
)
2684 MingwEmbeddedTypeLibModuleHandler::MingwEmbeddedTypeLibModuleHandler (
2685 const Module
& module_
)
2687 : MingwModuleHandler ( module_
)
2692 MingwEmbeddedTypeLibModuleHandler::Process ()
2699 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2701 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2705 MingwKernelModeDLLModuleHandler::Process ()
2707 GenerateKernelModeDLLModuleTarget ();
2711 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2713 string
targetMacro ( GetTargetMacro ( module
) );
2714 string workingDirectory
= GetWorkingDirectory ( );
2715 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2717 GenerateImportLibraryTargetIfNeeded ();
2719 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2723 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2725 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
2726 module
.GetEntryPoint(true).c_str (),
2727 module
.baseaddress
.c_str () );
2728 GenerateLinkerCommand ( dependencies
,
2734 GeneratePhonyTarget();
2739 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2740 const Module
& module_
)
2742 : MingwModuleHandler ( module_
)
2747 MingwKernelModeDriverModuleHandler::AddImplicitLibraries ( Module
& module
)
2749 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2753 MingwKernelModeDriverModuleHandler::Process ()
2755 GenerateKernelModeDriverModuleTarget ();
2760 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2762 string
targetMacro ( GetTargetMacro (module
) );
2763 string workingDirectory
= GetWorkingDirectory ();
2764 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2766 GenerateImportLibraryTargetIfNeeded ();
2768 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2772 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2774 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
2775 module
.GetEntryPoint(true).c_str (),
2776 module
.baseaddress
.c_str () );
2777 GenerateLinkerCommand ( dependencies
,
2783 GeneratePhonyTarget();
2788 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2789 const Module
& module_
)
2791 : MingwModuleHandler ( module_
)
2796 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2798 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2802 MingwNativeDLLModuleHandler::Process ()
2804 GenerateNativeDLLModuleTarget ();
2808 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2810 string
targetMacro ( GetTargetMacro (module
) );
2811 string workingDirectory
= GetWorkingDirectory ( );
2812 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2814 GenerateImportLibraryTargetIfNeeded ();
2816 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2820 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2822 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -shared",
2823 module
.GetEntryPoint(true).c_str (),
2824 module
.baseaddress
.c_str () );
2825 GenerateLinkerCommand ( dependencies
,
2831 GeneratePhonyTarget();
2836 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2837 const Module
& module_
)
2839 : MingwModuleHandler ( module_
)
2844 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2846 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2850 MingwNativeCUIModuleHandler::Process ()
2852 GenerateNativeCUIModuleTarget ();
2856 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2858 string
targetMacro ( GetTargetMacro (module
) );
2859 string workingDirectory
= GetWorkingDirectory ( );
2860 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2862 GenerateImportLibraryTargetIfNeeded ();
2864 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2868 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2870 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2871 module
.GetEntryPoint(true).c_str (),
2872 module
.baseaddress
.c_str () );
2873 GenerateLinkerCommand ( dependencies
,
2879 GeneratePhonyTarget();
2884 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2885 const Module
& module_
)
2887 : MingwModuleHandler ( module_
)
2891 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2892 const Module
& module_
)
2894 : MingwModuleHandler ( module_
)
2899 LinksToCrt( Module
&module
)
2901 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
2903 Library
& library
= *module
.non_if_data
.libraries
[i
];
2904 if ( library
.name
== "libcntpr" || library
.name
== "crt" )
2911 MingwAddImplicitLibraries( Module
&module
)
2916 if ( module
.type
!= Win32DLL
2917 && module
.type
!= Win32OCX
2918 && module
.type
!= Win32CUI
2919 && module
.type
!= Win32GUI
2920 && module
.type
!= Win32SCR
)
2922 // no implicit libraries
2926 links_to_crt
= LinksToCrt ( module
);
2928 if ( !module
.isDefaultEntryPoint
)
2930 if ( module
.GetEntryPoint(false) == "0" )
2932 if ( !links_to_crt
)
2934 pLibrary
= new Library ( module
, "mingw_common" );
2935 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() , pLibrary
);
2937 pLibrary
= new Library ( module
, "msvcrt" );
2938 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2939 links_to_crt
= true;
2945 if ( module
.IsDLL () )
2947 //pLibrary = new Library ( module, "__mingw_dllmain" );
2948 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2952 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2953 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2956 pLibrary
= new Library ( module
, "mingw_common" );
2957 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() + 1, pLibrary
);
2959 if ( !links_to_crt
)
2961 // always link in msvcrt to get the basic routines
2962 pLibrary
= new Library ( module
, "msvcrt" );
2963 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2968 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2970 MingwAddImplicitLibraries ( module
);
2971 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2975 MingwWin32DLLModuleHandler::Process ()
2977 GenerateWin32DLLModuleTarget ();
2981 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2983 string
targetMacro ( GetTargetMacro (module
) );
2984 string workingDirectory
= GetWorkingDirectory ( );
2985 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2987 GenerateImportLibraryTargetIfNeeded ();
2989 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2993 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2995 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
2996 module
.GetEntryPoint(true).c_str (),
2997 module
.baseaddress
.c_str () );
2998 GenerateLinkerCommand ( dependencies
,
3004 GeneratePhonyTarget();
3010 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
3012 MingwAddImplicitLibraries ( module
);
3013 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3017 MingwWin32OCXModuleHandler::Process ()
3019 GenerateWin32OCXModuleTarget ();
3023 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
3025 string
targetMacro ( GetTargetMacro (module
) );
3026 string workingDirectory
= GetWorkingDirectory ( );
3027 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3029 GenerateImportLibraryTargetIfNeeded ();
3031 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3035 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3037 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
3038 module
.GetEntryPoint(true).c_str (),
3039 module
.baseaddress
.c_str () );
3040 GenerateLinkerCommand ( dependencies
,
3046 GeneratePhonyTarget();
3051 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
3052 const Module
& module_
)
3054 : MingwModuleHandler ( module_
)
3059 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3061 MingwAddImplicitLibraries ( module
);
3062 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3066 MingwWin32CUIModuleHandler::Process ()
3068 GenerateWin32CUIModuleTarget ();
3072 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
3074 string
targetMacro ( GetTargetMacro (module
) );
3075 string workingDirectory
= GetWorkingDirectory ( );
3076 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3078 GenerateImportLibraryTargetIfNeeded ();
3080 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3084 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3086 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3087 module
.GetEntryPoint(true).c_str (),
3088 module
.baseaddress
.c_str () );
3089 GenerateLinkerCommand ( dependencies
,
3095 GeneratePhonyTarget();
3100 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
3101 const Module
& module_
)
3103 : MingwModuleHandler ( module_
)
3108 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3110 MingwAddImplicitLibraries ( module
);
3111 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3115 MingwWin32GUIModuleHandler::Process ()
3117 GenerateWin32GUIModuleTarget ();
3121 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
3123 string
targetMacro ( GetTargetMacro (module
) );
3124 string workingDirectory
= GetWorkingDirectory ( );
3125 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3127 GenerateImportLibraryTargetIfNeeded ();
3129 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3133 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3135 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3136 module
.GetEntryPoint(true).c_str (),
3137 module
.baseaddress
.c_str () );
3138 GenerateLinkerCommand ( dependencies
,
3144 GeneratePhonyTarget();
3149 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
3150 const Module
& module_
)
3152 : MingwModuleHandler ( module_
)
3157 MingwBootLoaderModuleHandler::Process ()
3159 GenerateBootLoaderModuleTarget ();
3163 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
3165 string
targetName ( module
.output
->name
);
3166 string
targetMacro ( GetTargetMacro (module
) );
3167 string workingDirectory
= GetWorkingDirectory ();
3168 FileLocation
junk_tmp ( TemporaryDirectory
,
3170 module
.name
+ ".junk.tmp" );
3171 CLEAN_FILE ( junk_tmp
);
3172 string objectsMacro
= GetObjectsMacro ( module
);
3173 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3174 string libsMacro
= GetLibsMacro ();
3178 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3179 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3180 targetMacro
.c_str (),
3181 objectsMacro
.c_str (),
3182 linkDepsMacro
.c_str (),
3183 backend
->GetFullPath ( *target_file
).c_str () );
3185 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
3187 if (Environment::GetArch() == "arm")
3189 fprintf ( fMakefile
,
3190 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
3191 backend
->GetFullName ( junk_tmp
).c_str (),
3192 objectsMacro
.c_str (),
3193 linkDepsMacro
.c_str (),
3194 GetLinkerMacro ().c_str ());
3198 fprintf ( fMakefile
,
3199 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
3200 backend
->GetFullName ( junk_tmp
).c_str (),
3201 objectsMacro
.c_str (),
3202 linkDepsMacro
.c_str (),
3203 GetLinkerMacro ().c_str ());
3205 fprintf ( fMakefile
,
3206 "\t${objcopy} -O binary %s $@\n",
3207 backend
->GetFullName ( junk_tmp
).c_str () );
3208 GenerateBuildMapCode ( &junk_tmp
);
3209 fprintf ( fMakefile
,
3210 "\t-@${rm} %s 2>$(NUL)\n",
3211 backend
->GetFullName ( junk_tmp
).c_str () );
3217 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
3218 const Module
& module_
)
3220 : MingwModuleHandler ( module_
)
3225 MingwBootSectorModuleHandler::Process ()
3227 GenerateBootSectorModuleTarget ();
3231 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
3233 string objectsMacro
= GetObjectsMacro ( module
);
3237 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3238 module
.name
.c_str ());
3239 fprintf ( fMakefile
,
3241 module
.name
.c_str (),
3242 objectsMacro
.c_str () );
3246 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
3247 const Module
& module_
)
3248 : MingwModuleHandler ( module_
)
3253 MingwBootProgramModuleHandler::Process ()
3255 GenerateBootProgramModuleTarget ();
3259 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3261 string
targetName ( module
.output
->name
);
3262 string
targetMacro ( GetTargetMacro (module
) );
3263 string workingDirectory
= GetWorkingDirectory ();
3264 FileLocation
junk_tmp ( TemporaryDirectory
,
3266 module
.name
+ ".junk.tmp" );
3267 FileLocation
junk_elf ( TemporaryDirectory
,
3269 module
.name
+ ".junk.elf" );
3270 FileLocation
junk_cpy ( TemporaryDirectory
,
3272 module
.name
+ ".junk.elf" );
3273 CLEAN_FILE ( junk_tmp
);
3274 CLEAN_FILE ( junk_elf
);
3275 CLEAN_FILE ( junk_cpy
);
3276 string objectsMacro
= GetObjectsMacro ( module
);
3277 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3278 string libsMacro
= GetLibsMacro ();
3279 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3283 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3284 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3285 targetMacro
.c_str (),
3286 objectsMacro
.c_str (),
3287 linkDepsMacro
.c_str (),
3288 payload
->name
.c_str (),
3289 backend
->GetFullPath ( *target_file
).c_str () );
3291 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3293 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3294 module
.buildtype
.c_str (),
3295 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3296 backend
->GetFullName ( junk_cpy
).c_str () );
3298 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3299 module
.buildtype
.c_str (),
3300 backend
->GetFullName ( junk_cpy
).c_str (),
3301 backend
->GetFullName ( junk_tmp
).c_str () );
3303 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3304 module
.buildtype
.c_str (),
3305 linkDepsMacro
.c_str (),
3306 backend
->GetFullName ( junk_tmp
).c_str (),
3307 backend
->GetFullName ( junk_elf
).c_str () );
3309 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3310 module
.buildtype
.c_str (),
3311 backend
->GetFullName ( junk_elf
).c_str (),
3312 backend
->GetFullName ( *module
.output
) .c_str () );
3314 fprintf ( fMakefile
,
3315 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3316 backend
->GetFullName ( junk_tmp
).c_str (),
3317 backend
->GetFullName ( junk_elf
).c_str (),
3318 backend
->GetFullName ( junk_cpy
).c_str () );
3324 MingwIsoModuleHandler::MingwIsoModuleHandler (
3325 const Module
& module_
)
3327 : MingwModuleHandler ( module_
)
3332 MingwIsoModuleHandler::Process ()
3334 GenerateIsoModuleTarget ();
3338 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3339 const string
& bootcdDirectory
)
3341 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3343 const Module
& m
= *module
.project
.modules
[i
];
3346 if ( m
.bootstrap
!= NULL
)
3348 FileLocation
targetFile ( OutputDirectory
,
3349 m
.bootstrap
->base
.length () > 0
3350 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3352 m
.bootstrap
->nameoncd
);
3353 OutputCopyCommand ( *m
.output
, targetFile
);
3359 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3360 const string
& bootcdDirectory
)
3362 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3364 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3365 FileLocation
targetFile ( OutputDirectory
,
3366 cdfile
.target
->relative_path
.length () > 0
3367 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3369 cdfile
.target
->name
);
3370 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3375 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3376 const string
& bootcdDirectory
)
3378 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3380 const Module
& m
= *module
.project
.modules
[i
];
3383 if ( m
.bootstrap
!= NULL
)
3385 FileLocation
targetDirectory ( OutputDirectory
,
3386 m
.bootstrap
->base
.length () > 0
3387 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3390 out
.push_back ( targetDirectory
);
3396 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3397 const string
& bootcdDirectory
)
3399 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3401 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3402 FileLocation
targetDirectory ( OutputDirectory
,
3403 cdfile
.target
->relative_path
.length () > 0
3404 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3407 out
.push_back( targetDirectory
);
3412 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3413 const string
& bootcdDirectory
)
3415 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3416 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3420 MingwIsoModuleHandler::GetBootstrapCdFiles (
3421 vector
<FileLocation
>& out
) const
3423 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3425 const Module
& m
= *module
.project
.modules
[i
];
3428 if ( m
.bootstrap
!= NULL
)
3430 out
.push_back ( *m
.output
);
3436 MingwIsoModuleHandler::GetNonModuleCdFiles (
3437 vector
<FileLocation
>& out
) const
3439 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3441 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3442 out
.push_back ( *cdfile
.source
);
3447 MingwIsoModuleHandler::GetCdFiles (
3448 vector
<FileLocation
>& out
) const
3450 GetBootstrapCdFiles ( out
);
3451 GetNonModuleCdFiles ( out
);
3455 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3457 string bootcdDirectory
= "cd";
3458 FileLocation
bootcd ( OutputDirectory
,
3461 FileLocation
bootcdReactos ( OutputDirectory
,
3462 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3464 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3465 vector
<FileLocation
> vCdDirectories
;
3468 FileLocation
srcunattend ( SourceDirectory
,
3469 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3471 FileLocation
tarunattend ( bootcdReactos
.directory
,
3472 bootcdReactos
.relative_path
,
3474 if (module
.type
== IsoRegTest
)
3475 vSourceFiles
.push_back ( srcunattend
);
3478 const Module
* bootModule
;
3479 bootModule
= module
.project
.LocateModule ( module
.type
== IsoRegTest
3482 const FileLocation
*isoboot
= bootModule
->output
;
3483 vSourceFiles
.push_back ( *isoboot
);
3485 // prepare reactos.dff and reactos.inf
3486 FileLocation
reactosDff ( SourceDirectory
,
3487 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3489 FileLocation
reactosInf ( bootcdReactos
.directory
,
3490 bootcdReactos
.relative_path
,
3493 vSourceFiles
.push_back ( reactosDff
);
3497 if (module
.type
== IsoRegTest
)
3498 IsoName
= "ReactOS-RegTest.iso";
3500 IsoName
= "ReactOS.iso";
3503 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3506 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3507 GetCdFiles ( vCdFiles
);
3508 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3509 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3511 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3512 module
.name
.c_str ());
3513 fprintf ( fMakefile
,
3514 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3515 module
.name
.c_str (),
3516 backend
->GetFullName ( *isoboot
).c_str (),
3517 sourceFiles
.c_str (),
3519 cdDirectories
.c_str () );
3520 fprintf ( fMakefile
,
3521 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3522 backend
->GetFullName ( reactosDff
).c_str (),
3523 backend
->GetFullPath ( bootcdReactos
).c_str () );
3524 fprintf ( fMakefile
,
3525 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3526 backend
->GetFullName ( reactosDff
).c_str (),
3527 backend
->GetFullName ( reactosInf
).c_str (),
3528 backend
->GetFullPath ( bootcdReactos
).c_str ());
3529 fprintf ( fMakefile
,
3530 "\t-@${rm} %s 2>$(NUL)\n",
3531 backend
->GetFullName ( reactosInf
).c_str () );
3532 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3533 OutputCdfileCopyCommands ( bootcdDirectory
);
3535 if (module
.type
== IsoRegTest
)
3536 OutputCopyCommand ( srcunattend
, tarunattend
);
3538 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3539 fprintf ( fMakefile
,
3540 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3541 backend
->GetFullName ( *isoboot
).c_str (),
3542 backend
->GetFullPath ( bootcd
).c_str (),
3544 fprintf ( fMakefile
,
3549 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3550 const Module
& module_
)
3552 : MingwModuleHandler ( module_
)
3557 MingwLiveIsoModuleHandler::Process ()
3559 GenerateLiveIsoModuleTarget ();
3563 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3565 FileLocation
dir ( OutputDirectory
,
3568 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3572 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3573 string
& reactosDirectory
)
3575 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3577 const Module
& m
= *module
.project
.modules
[i
];
3582 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3583 FileLocation
destination ( OutputDirectory
,
3584 m
.install
->relative_path
.length () > 0
3585 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3586 : livecdDirectory
+ sSep
+ reactosDirectory
,
3588 OutputCopyCommand ( *aliasedModule
.output
,
3595 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3596 string
& reactosDirectory
)
3598 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3600 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3601 FileLocation
target ( OutputDirectory
,
3602 installfile
.target
->relative_path
.length () > 0
3603 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3604 : livecdDirectory
+ sSep
+ reactosDirectory
,
3605 installfile
.target
->name
);
3606 OutputCopyCommand ( *installfile
.source
, target
);
3611 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3613 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3614 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3615 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3616 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3617 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3618 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3620 FileLocation
livecdIni ( SourceDirectory
,
3621 "boot" + sSep
+ "bootdata",
3623 FileLocation
destination ( OutputDirectory
,
3626 OutputCopyCommand ( livecdIni
,
3631 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3633 FileLocation
freeldr ( OutputDirectory
,
3634 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3636 FileLocation
destination ( OutputDirectory
,
3637 livecdDirectory
+ sSep
+ "loader",
3639 OutputCopyCommand ( freeldr
,
3644 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3646 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3647 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3649 fprintf ( fMakefile
,
3650 "\t$(ECHO_MKHIVE)\n" );
3651 fprintf ( fMakefile
,
3652 "\t$(MKHIVE_TARGET) boot%cbootdata %s boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst.inf\n",
3653 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3654 cSep
, cSep
, cSep
, cSep
);
3658 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3660 string livecdDirectory
= module
.name
;
3661 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3665 const Module
* bootModule
;
3666 bootModule
= module
.project
.LocateModule ( module
.name
== "livecdregtest"
3669 const FileLocation
*isoboot
= bootModule
->output
;
3670 if (module
.name
== "livecdregtest")
3671 IsoName
= "ReactOS-LiveCD-RegTest.iso";
3673 IsoName
= "ReactOS-LiveCD.iso";
3675 string reactosDirectory
= "reactos";
3676 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3677 FileLocation
livecdReactos ( OutputDirectory
,
3678 livecdReactosNoFixup
,
3680 CLEAN_FILE ( livecdReactos
);
3682 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3683 module
.name
.c_str ());
3684 fprintf ( fMakefile
,
3685 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3686 module
.name
.c_str (),
3687 backend
->GetFullName ( *isoboot
) .c_str (),
3688 backend
->GetFullPath ( livecdReactos
).c_str () );
3689 OutputModuleCopyCommands ( livecdDirectory
,
3691 OutputNonModuleCopyCommands ( livecdDirectory
,
3693 OutputProfilesDirectoryCommands ( livecdDirectory
);
3694 OutputLoaderCommands ( livecdDirectory
);
3695 OutputRegistryCommands ( livecdDirectory
);
3696 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3697 fprintf ( fMakefile
,
3698 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3699 backend
->GetFullName( *isoboot
).c_str (),
3700 backend
->GetFullPath ( livecd
).c_str (),
3702 fprintf ( fMakefile
,
3707 MingwTestModuleHandler::MingwTestModuleHandler (
3708 const Module
& module_
)
3710 : MingwModuleHandler ( module_
)
3715 MingwTestModuleHandler::Process ()
3717 GenerateTestModuleTarget ();
3720 /* caller needs to delete the returned object */
3722 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3724 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3725 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3726 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3730 MingwTestModuleHandler::GenerateTestModuleTarget ()
3732 string
targetMacro ( GetTargetMacro ( module
) );
3733 string workingDirectory
= GetWorkingDirectory ( );
3734 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3736 GenerateImportLibraryTargetIfNeeded ();
3738 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3742 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3744 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
3745 module
.GetEntryPoint(true).c_str (),
3746 module
.baseaddress
.c_str () );
3747 GenerateLinkerCommand ( dependencies
,
3753 GeneratePhonyTarget();
3758 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
3759 const Module
& module_
)
3761 : MingwModuleHandler ( module_
)
3766 MingwRpcServerModuleHandler::Process ()
3772 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
3773 const Module
& module_
)
3775 : MingwModuleHandler ( module_
)
3780 MingwRpcClientModuleHandler::Process ()
3786 MingwRpcProxyModuleHandler::MingwRpcProxyModuleHandler (
3787 const Module
& module_
)
3789 : MingwModuleHandler ( module_
)
3794 MingwRpcProxyModuleHandler::Process ()
3800 MingwAliasModuleHandler::MingwAliasModuleHandler (
3801 const Module
& module_
)
3803 : MingwModuleHandler ( module_
)
3808 MingwAliasModuleHandler::Process ()
3812 MingwIdlHeaderModuleHandler::MingwIdlHeaderModuleHandler (
3813 const Module
& module_
)
3815 : MingwModuleHandler ( module_
)
3820 MingwIdlHeaderModuleHandler::Process ()
3825 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3826 const Module
& module_
)
3828 : MingwModuleHandler ( module_
)
3833 MingwCabinetModuleHandler::Process ()
3835 string
targetMacro ( GetTargetMacro (module
) );
3839 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3840 fprintf ( fMakefile
, "%s: | %s\n",
3841 targetMacro
.c_str (),
3842 backend
->GetFullPath ( *target_file
).c_str () );
3844 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3845 fprintf ( fMakefile
,
3846 "\t$(Q)$(cabman_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3847 targetMacro
.c_str (),
3848 module
.name
.c_str());
3851 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3852 const Module
& module_
)
3854 : MingwModuleHandler ( module_
)
3859 MingwElfExecutableModuleHandler::Process ()
3861 string
targetName ( module
.output
->name
);
3862 string
targetMacro ( GetTargetMacro (module
) );
3863 string workingDirectory
= GetWorkingDirectory ();
3864 string objectsMacro
= GetObjectsMacro ( module
);
3865 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3866 string libsMacro
= GetLibsMacro ();
3870 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3871 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3872 targetMacro
.c_str (),
3873 objectsMacro
.c_str (),
3874 linkDepsMacro
.c_str (),
3875 backend
->GetFullPath ( *target_file
).c_str () );
3877 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3879 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3880 module
.buildtype
.c_str(),
3881 objectsMacro
.c_str(),
3883 targetMacro
.c_str () );