2 * Copyright (C) 2005 Casper S. Hornstrup
3 * 2007-2008 Hervé Poussineau
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "../../pch.h"
23 #include "../../rbuild.h"
25 #include "modulehandler.h"
32 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
33 #define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
36 MingwModuleHandler::backend
= NULL
;
38 MingwModuleHandler::fMakefile
= NULL
;
42 const string
& filename
,
43 const string
& prefix
)
45 if ( !prefix
.length() )
48 const char* pfilename
= filename
.c_str();
49 const char* p1
= strrchr ( pfilename
, '/' );
50 const char* p2
= strrchr ( pfilename
, '\\' );
55 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
58 out
+= prefix
+ pfilename
;
63 GetTargetMacro ( const Module
& module
, bool with_dollar
)
65 string
s ( module
.name
);
69 return ssprintf ( "$(%s)", s
.c_str() );
73 MingwModuleHandler::MingwModuleHandler (
74 const Module
& module_
)
81 MingwModuleHandler::~MingwModuleHandler()
86 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
92 MingwModuleHandler::SetMakefile ( FILE* f
)
98 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
103 /*static*/ const FileLocation
*
104 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
106 switch ( file
->directory
)
108 case SourceDirectory
:
110 case IntermediateDirectory
:
111 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
113 case OutputDirectory
:
114 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
116 case InstallDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
120 throw InvalidOperationException ( __FILE__
,
122 "Invalid directory %d.",
129 /* caller needs to delete the returned object */
131 MingwModuleHandler::GetTargetFilename (
132 const Module
& module
,
133 string_list
* pclean_files
)
135 FileLocation
*target
= new FileLocation ( *module
.output
);
138 string_list
& clean_files
= *pclean_files
;
139 CLEAN_FILE ( *target
);
144 /* caller needs to delete the returned object */
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 FileLocation
*target
= new FileLocation ( *module
.dependency
);
153 string_list
& clean_files
= *pclean_files
;
154 CLEAN_FILE ( *target
);
159 /* caller needs to delete the returned object */
161 MingwModuleHandler::InstanciateHandler (
162 const Module
& module
,
163 MingwBackend
* backend
)
165 MingwModuleHandler
* handler
;
166 switch ( module
.type
)
169 handler
= new MingwBuildToolModuleHandler ( module
);
172 handler
= new MingwStaticLibraryModuleHandler ( module
);
174 case HostStaticLibrary
:
175 handler
= new MingwHostStaticLibraryModuleHandler ( module
);
178 handler
= new MingwObjectLibraryModuleHandler ( module
);
181 handler
= new MingwKernelModuleHandler ( module
);
184 handler
= new MingwNativeCUIModuleHandler ( module
);
187 handler
= new MingwWin32CUIModuleHandler ( module
);
191 handler
= new MingwWin32GUIModuleHandler ( module
);
195 handler
= new MingwKernelModeDLLModuleHandler ( module
);
198 handler
= new MingwNativeDLLModuleHandler ( module
);
201 handler
= new MingwWin32DLLModuleHandler ( module
);
204 handler
= new MingwWin32OCXModuleHandler ( module
);
206 case KernelModeDriver
:
207 handler
= new MingwKernelModeDriverModuleHandler ( module
);
210 handler
= new MingwBootLoaderModuleHandler ( module
);
213 handler
= new MingwBootSectorModuleHandler ( module
);
216 handler
= new MingwBootProgramModuleHandler ( module
);
219 handler
= new MingwIsoModuleHandler ( module
);
222 handler
= new MingwLiveIsoModuleHandler ( module
);
225 handler
= new MingwIsoModuleHandler ( module
);
228 handler
= new MingwLiveIsoModuleHandler ( module
);
231 handler
= new MingwTestModuleHandler ( module
);
234 handler
= new MingwRpcServerModuleHandler ( module
);
237 handler
= new MingwRpcClientModuleHandler ( module
);
240 handler
= new MingwRpcProxyModuleHandler ( module
);
243 handler
= new MingwAliasModuleHandler ( module
);
246 handler
= new MingwMessageHeaderModuleHandler (module
);
249 handler
= new MingwIdlHeaderModuleHandler ( module
);
252 handler
= new MingwCabinetModuleHandler ( module
);
254 case EmbeddedTypeLib
:
255 handler
= new MingwEmbeddedTypeLibModuleHandler ( module
);
258 handler
= new MingwElfExecutableModuleHandler ( module
);
261 throw UnknownModuleTypeException (
262 module
.node
.location
,
270 MingwModuleHandler::GetWorkingDirectory () const
276 MingwModuleHandler::GetBasename ( const string
& filename
) const
278 size_t index
= filename
.find_last_of ( '.' );
279 if ( index
!= string::npos
)
280 return filename
.substr ( 0, index
);
285 MingwModuleHandler::GetExtraDependencies (
286 const FileLocation
*file
) const
288 string extension
= GetExtension ( *file
);
289 if ( extension
== ".idl" || extension
== ".IDL" )
291 const FileLocation
*header
;
292 switch ( module
.type
)
294 case RpcServer
: header
= GetRpcServerHeaderFilename ( file
); break;
295 case RpcClient
: header
= GetRpcClientHeaderFilename ( file
); break;
296 case RpcProxy
: header
= GetRpcProxyHeaderFilename ( file
); break;
297 case IdlHeader
: header
= GetIdlHeaderFilename ( file
); break;
298 default: header
= NULL
; break;
303 string dependencies
= backend
->GetFullName ( *header
);
305 return " " + dependencies
;
312 MingwModuleHandler::GetCompilationUnitDependencies (
313 const CompilationUnit
& compilationUnit
) const
315 if ( compilationUnit
.GetFiles ().size () <= 1 )
317 vector
<string
> sourceFiles
;
318 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
320 const File
& file
= *compilationUnit
.GetFiles ()[i
];
321 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
323 return string ( " " ) + v2s ( sourceFiles
, 10 );
326 /* caller needs to delete the returned object */
328 MingwModuleHandler::GetModuleArchiveFilename () const
330 if ( IsStaticLibrary ( module
) )
331 return GetTargetFilename ( module
, NULL
);
332 return new FileLocation ( IntermediateDirectory
,
333 module
.output
->relative_path
,
334 ReplaceExtension ( module
.name
, ".temp.a" ) );
338 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
340 string extension
= GetExtension ( file
.file
);
341 return ( extension
== ".spec" || extension
== ".SPEC" );
345 MingwModuleHandler::ReferenceObjects (
346 const Module
& module
)
348 if ( module
.type
== ObjectLibrary
)
350 if ( module
.type
== RpcServer
)
352 if ( module
.type
== RpcClient
)
354 if ( module
.type
== RpcProxy
)
356 if ( module
.type
== IdlHeader
)
358 if ( module
.type
== MessageHeader
)
364 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
365 const FileLocation
& destination
)
370 "\t${cp} %s %s 1>$(NUL)\n",
371 backend
->GetFullName ( source
).c_str (),
372 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
376 MingwModuleHandler::GetImportLibraryDependency (
377 const Module
& importedModule
)
380 if ( ReferenceObjects ( importedModule
) )
382 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
385 dep
= GetTargetMacro ( importedModule
);
386 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
388 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
389 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
390 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
391 if ( GetExtension ( *objectFilename
) == ".h" )
392 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
393 else if ( GetExtension ( *objectFilename
) == ".rc" )
394 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
399 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
400 dep
= backend
->GetFullName ( *library_target
);
401 delete library_target
;
407 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
408 string_list
& targets
)
410 if ( dependencyModule
.invocations
.size () > 0 )
412 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
414 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
415 invoke
.GetTargets ( targets
);
419 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
423 MingwModuleHandler::GetModuleDependencies (
424 string_list
& dependencies
)
426 size_t iend
= module
.dependencies
.size ();
431 for ( size_t i
= 0; i
< iend
; i
++ )
433 const Dependency
& dependency
= *module
.dependencies
[i
];
434 const Module
& dependencyModule
= *dependency
.dependencyModule
;
435 GetTargets ( dependencyModule
,
438 vector
<FileLocation
> v
;
439 GetDefinitionDependencies ( v
);
441 for ( size_t i
= 0; i
< v
.size (); i
++ )
443 const FileLocation
& file
= v
[i
];
444 dependencies
.push_back ( backend
->GetFullName ( file
) );
448 /* caller needs to delete the returned object */
450 MingwModuleHandler::GetObjectFilename (
451 const FileLocation
* sourceFile
,
452 const Module
& module
) const
454 DirectoryLocation destination_directory
;
456 string extension
= GetExtension ( *sourceFile
);
458 if ( module
.type
== BootSector
)
459 return new FileLocation ( *module
.output
);
460 else if ( extension
== ".rc" || extension
== ".RC" )
461 newExtension
= "_" + module
.name
+ ".coff";
462 else if ( extension
== ".mc" || extension
== ".MC" )
463 newExtension
= ".rc";
464 else if ( extension
== ".spec" || extension
== ".SPEC" )
465 newExtension
= ".stubs.o";
466 else if ( extension
== ".idl" || extension
== ".IDL" )
468 if ( module
.type
== RpcServer
)
469 newExtension
= "_s.o";
470 else if ( module
.type
== RpcClient
)
471 newExtension
= "_c.o";
472 else if ( module
.type
== RpcProxy
)
473 newExtension
= "_p.o";
478 newExtension
= "_" + module
.name
+ ".o";
480 if ( module
.type
== BootSector
)
481 destination_directory
= OutputDirectory
;
483 destination_directory
= IntermediateDirectory
;
485 const FileLocation
*obj_file
= new FileLocation(
486 destination_directory
,
487 sourceFile
->relative_path
,
488 ReplaceExtension ( sourceFile
->name
, newExtension
) );
489 PassThruCacheDirectory ( obj_file
);
495 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
497 return module
.name
+ "_clean";
501 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
503 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
505 Library
& library
= *module
.non_if_data
.libraries
[i
];
506 if ( library
.importedModule
->type
== ObjectLibrary
)
507 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
512 MingwModuleHandler::GenerateCleanTarget () const
514 if ( module
.type
== Alias
)
518 ".PHONY: %s_clean\n",
519 module
.name
.c_str() );
520 vector
<string
> referencedModuleNames
;
521 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
524 GetModuleCleanTarget ( module
).c_str(),
525 v2s ( referencedModuleNames
, 10 ).c_str () );
526 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
528 if ( ( i
+ 1 ) % 10 == 9 )
529 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
530 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
532 fprintf ( fMakefile
, " 2>$(NUL)\n" );
534 if( ProxyMakefile::GenerateProxyMakefile(module
) )
536 DirectoryLocation root
;
538 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
539 root
= SourceDirectory
;
541 root
= OutputDirectory
;
543 FileLocation
proxyMakefile ( root
,
544 module
.output
->relative_path
,
546 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
547 backend
->GetFullName ( proxyMakefile
).c_str () );
550 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
554 MingwModuleHandler::GenerateInstallTarget () const
556 if ( !module
.install
)
558 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
561 module
.name
.c_str (),
562 backend
->GetFullName ( *module
.install
).c_str () );
566 MingwModuleHandler::GenerateDependsTarget () const
569 ".PHONY: %s_depends\n",
570 module
.name
.c_str() );
572 "%s_depends: $(RBUILD_TARGET)\n",
573 module
.name
.c_str () );
575 "\t$(ECHO_RBUILD)\n" );
577 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
578 module
.name
.c_str () );
582 MingwModuleHandler::GetObjectFilenames ()
584 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
585 if ( compilationUnits
.size () == 0 )
588 string
objectFilenames ( "" );
589 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
591 if ( objectFilenames
.size () > 0 )
592 objectFilenames
+= " ";
593 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
594 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
595 objectFilenames
+= backend
->GetFullName ( *object_file
);
598 return objectFilenames
;
602 MingwModuleHandler::GenerateGccDefineParametersFromVector (
603 const vector
<Define
*>& defines
,
604 set
<string
>& used_defs
)
608 for ( size_t i
= 0; i
< defines
.size (); i
++ )
610 Define
& define
= *defines
[i
];
611 if (used_defs
.find(define
.name
) != used_defs
.end())
613 if (parameters
.length () > 0)
615 if (define
.name
.find('(') != string::npos
)
616 parameters
+= "$(QT)";
618 parameters
+= define
.name
;
619 if (define
.value
.length () > 0)
622 parameters
+= define
.value
;
624 if (define
.name
.find('(') != string::npos
)
625 parameters
+= "$(QT)";
626 used_defs
.insert(used_defs
.begin(),define
.name
);
632 MingwModuleHandler::GenerateGccDefineParameters () const
634 set
<string
> used_defs
;
635 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
, used_defs
);
636 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
, used_defs
);
637 if ( s
.length () > 0 )
646 MingwModuleHandler::ConcatenatePaths (
648 const string
& path2
) const
650 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
652 if ( path1
[path1
.length ()] == cSep
)
653 return path1
+ path2
;
655 return path1
+ cSep
+ path2
;
659 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
661 string parameters
, path_prefix
;
662 for ( size_t i
= 0; i
< includes
.size (); i
++ )
664 Include
& include
= *includes
[i
];
665 if ( parameters
.length () > 0 )
667 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
673 MingwModuleHandler::GenerateGccIncludeParameters () const
675 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
676 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
677 if ( s
.length () > 0 )
686 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
689 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
691 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
692 if ( compilerFlag
.compiler
== type
)
693 parameters
+= " " + compilerFlag
.flag
;
699 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
702 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
704 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
705 if ( parameters
.length () > 0 )
707 parameters
+= linkerFlag
.flag
;
713 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
714 const vector
<Library
*>& libraries
)
716 string
dependencies ( "" );
718 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
720 if ( wrap_count
++ == 5 )
721 dependencies
+= " \\\n\t\t", wrap_count
= 0;
722 else if ( dependencies
.size () > 0 )
724 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
730 MingwModuleHandler::GenerateLinkerParameters () const
732 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
736 MingwModuleHandler::GenerateMacro (
737 const char* assignmentOperation
,
739 const IfableData
& data
,
740 set
<const Define
*> *used_defs
,
741 bool generatingCompilerMacro
)
744 bool generateAssignment
;
746 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
747 if ( generatingCompilerMacro
)
748 generateAssignment
|= data
.compilerFlags
.size () > 0;
749 if ( generateAssignment
)
754 assignmentOperation
);
757 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
762 backend
->GetFullPath ( *pchFilename
).c_str () );
766 if ( generatingCompilerMacro
)
768 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
769 if ( compilerParameters
.size () > 0 )
774 compilerParameters
.c_str () );
777 for ( i
= 0; i
< data
.includes
.size(); i
++ )
779 const Include
& include
= *data
.includes
[i
];
780 const FileLocation
* includeDirectory
= include
.directory
;
784 backend
->GetFullPath ( *includeDirectory
).c_str() );
786 for ( i
= 0; i
< data
.defines
.size(); i
++ )
788 const Define
& define
= *data
.defines
[i
];
791 set
<const Define
*>::const_iterator last_define
;
792 for (last_define
= used_defs
->begin ();
793 last_define
!= used_defs
->end ();
796 if ( (*last_define
)->name
!= define
.name
)
798 if ( !define
.overridable
)
800 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
802 "Invalid override of define '%s', already defined at %s",
803 define
.name
.c_str (),
804 define
.node
->location
.c_str () );
806 if ( backend
->configuration
.Verbose
)
807 printf("%s: Overriding '%s' already defined at %s\n",
808 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
809 define
.node
->location
.c_str () );
812 if ( last_define
!= used_defs
->end () )
818 define
.name
.c_str() );
819 if (define
.value
.length () > 0)
823 define
.value
.c_str() );
825 used_defs
->insert( used_defs
->begin (), &define
);
827 if ( generateAssignment
)
829 fprintf ( fMakefile
, "\n" );
834 MingwModuleHandler::GenerateMacros (
835 const char* assignmentOperation
,
836 const IfableData
& data
,
837 const vector
<LinkerFlag
*>* linkerFlags
,
838 set
<const Define
*>& used_defs
)
842 GenerateMacro ( assignmentOperation
,
847 GenerateMacro ( assignmentOperation
,
853 if ( linkerFlags
!= NULL
)
855 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
856 if ( linkerParameters
.size () > 0 )
861 linkerflagsMacro
.c_str (),
863 linkerParameters
.c_str() );
867 if ( data
.libraries
.size () > 0 )
869 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
870 if ( deps
.size () > 0 )
881 const vector
<If
*>& ifs
= data
.ifs
;
882 for ( i
= 0; i
< ifs
.size(); i
++ )
885 if ( rIf
.data
.defines
.size()
886 || rIf
.data
.includes
.size()
887 || rIf
.data
.libraries
.size()
888 || rIf
.data
.compilationUnits
.size()
889 || rIf
.data
.compilerFlags
.size()
890 || rIf
.data
.ifs
.size() )
894 "%s (\"$(%s)\",\"%s\")\n",
895 rIf
.negated
? "ifneq" : "ifeq",
896 rIf
.property
.c_str(),
911 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
913 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
914 delete compilationUnits
[i
];
918 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
923 MingwModuleHandler::GenerateSourceMacros (
924 const char* assignmentOperation
,
925 const IfableData
& data
)
929 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
930 vector
<const FileLocation
*> headers
;
931 if ( compilationUnits
.size () > 0 )
936 sourcesMacro
.c_str (),
937 assignmentOperation
);
938 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
940 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
941 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
945 ( i
%10 == 9 ? " \\\n\t" : " " ),
946 backend
->GetFullName ( compilationName
).c_str () );
948 fprintf ( fMakefile
, "\n" );
951 const vector
<If
*>& ifs
= data
.ifs
;
952 for ( i
= 0; i
< ifs
.size(); i
++ )
955 if ( rIf
.data
.defines
.size()
956 || rIf
.data
.includes
.size()
957 || rIf
.data
.libraries
.size()
958 || rIf
.data
.compilationUnits
.size()
959 || rIf
.data
.compilerFlags
.size()
960 || rIf
.data
.ifs
.size() )
964 "%s (\"$(%s)\",\"%s\")\n",
965 rIf
.negated
? "ifneq" : "ifeq",
966 rIf
.property
.c_str(),
968 GenerateSourceMacros (
977 vector
<CompilationUnit
*> sourceCompilationUnits
;
978 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
979 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
981 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
985 sourcesMacro
.c_str(),
986 backend
->GetFullName ( compilationName
).c_str () );
988 CleanupCompilationUnitVector ( sourceCompilationUnits
);
992 MingwModuleHandler::GenerateObjectMacros (
993 const char* assignmentOperation
,
994 const IfableData
& data
)
998 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
999 vector
<const FileLocation
*> headers
;
1000 vector
<const FileLocation
*> mcheaders
;
1001 vector
<const FileLocation
*> mcresources
;
1002 if ( compilationUnits
.size () > 0 )
1004 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1006 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1007 if ( compilationUnit
.IsFirstFile () )
1009 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1010 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1011 fprintf ( fMakefile
,
1013 objectsMacro
.c_str(),
1014 backend
->GetFullName ( *object_file
).c_str (),
1015 objectsMacro
.c_str() );
1022 objectsMacro
.c_str (),
1023 assignmentOperation
);
1024 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
1026 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1027 if ( !compilationUnit
.IsFirstFile () )
1029 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1030 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1031 if ( GetExtension ( *objectFilename
) == ".h" )
1032 headers
.push_back ( objectFilename
);
1033 else if ( GetExtension ( *objectFilename
) == ".rc" )
1035 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
1036 mcheaders
.push_back ( headerFilename
);
1037 mcresources
.push_back ( objectFilename
);
1044 ( i
%10 == 9 ? " \\\n\t" : " " ),
1045 backend
->GetFullName ( *objectFilename
).c_str () );
1046 delete objectFilename
;
1050 fprintf ( fMakefile
, "\n" );
1052 if ( headers
.size () > 0 )
1057 module
.name
.c_str (),
1058 assignmentOperation
);
1059 for ( i
= 0; i
< headers
.size (); i
++ )
1064 ( i
%10 == 9 ? " \\\n\t" : " " ),
1065 backend
->GetFullName ( *headers
[i
] ).c_str () );
1068 fprintf ( fMakefile
, "\n" );
1071 if ( mcheaders
.size () > 0 )
1076 module
.name
.c_str (),
1077 assignmentOperation
);
1078 for ( i
= 0; i
< mcheaders
.size (); i
++ )
1083 ( i
%10 == 9 ? " \\\n\t" : " " ),
1084 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
1085 delete mcheaders
[i
];
1087 fprintf ( fMakefile
, "\n" );
1090 if ( mcresources
.size () > 0 )
1095 module
.name
.c_str (),
1096 assignmentOperation
);
1097 for ( i
= 0; i
< mcresources
.size (); i
++ )
1102 ( i
%10 == 9 ? " \\\n\t" : " " ),
1103 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
1104 delete mcresources
[i
];
1106 fprintf ( fMakefile
, "\n" );
1109 const vector
<If
*>& ifs
= data
.ifs
;
1110 for ( i
= 0; i
< ifs
.size(); i
++ )
1113 if ( rIf
.data
.defines
.size()
1114 || rIf
.data
.includes
.size()
1115 || rIf
.data
.libraries
.size()
1116 || rIf
.data
.compilationUnits
.size()
1117 || rIf
.data
.compilerFlags
.size()
1118 || rIf
.data
.ifs
.size() )
1122 "%s (\"$(%s)\",\"%s\")\n",
1123 rIf
.negated
? "ifneq" : "ifeq",
1124 rIf
.property
.c_str(),
1125 rIf
.value
.c_str() );
1126 GenerateObjectMacros (
1135 vector
<CompilationUnit
*> sourceCompilationUnits
;
1136 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1137 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1139 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1140 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1144 objectsMacro
.c_str(),
1145 backend
->GetFullName ( *object_file
).c_str () );
1148 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1151 /* caller needs to delete the returned object */
1153 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1155 if ( !module
.pch
|| !use_pch
)
1157 return new FileLocation ( IntermediateDirectory
,
1158 module
.pch
->file
->relative_path
,
1159 module
.pch
->file
->name
+ ".gch" );
1162 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1163 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1164 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1165 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1166 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1168 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1169 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1171 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1172 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1174 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1175 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1176 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1177 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1178 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1180 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1181 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1182 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1183 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1185 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1186 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1187 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1188 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1189 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1191 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1192 "\t$(Q)$(WRC_TARGET) ${$(module_name)_RCFLAGS} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp\n"
1193 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1194 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1195 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1196 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1197 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1198 Rule
wmcRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(WMC_TARGET) $(source) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1200 "\t$(Q)$(WMC_TARGET) -i -H $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h -o $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(source)\n",
1201 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1202 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1203 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1204 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1205 "\t$(ECHO_WINEBLD)\n"
1206 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source)\n"
1207 "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1208 "\t$(ECHO_WINEBLD)\n"
1209 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c --pedll $(source_path)$(SEP)$(source_name_noext).spec\n"
1210 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1212 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1213 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
1214 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
1215 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
1216 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1217 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1218 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1220 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1221 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1222 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1223 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1224 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1226 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h -s -S $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(source)\n"
1227 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1229 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1230 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1231 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1232 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1233 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1234 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1235 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1237 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h -c -C $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(source)\n"
1238 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1240 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1241 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1242 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1243 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1244 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1245 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1246 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1248 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h -p -P $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(source)\n"
1249 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1251 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1252 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1253 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1254 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1255 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1256 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1257 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1259 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1260 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1261 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1262 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1264 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1265 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1266 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1267 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1269 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1270 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1271 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1272 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1274 "\t${gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1275 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1276 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1277 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1279 "\t${host_gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1280 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1281 Rule
emptyRule ( "", NULL
);
1284 MingwModuleHandler::GenerateGccCommand (
1285 const FileLocation
* sourceFile
,
1287 const string
& extraDependencies
)
1289 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1290 string dependencies
= extraDependencies
;
1293 string extension
= GetExtension ( *sourceFile
);
1294 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1295 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1297 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1301 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1305 /* WIDL generated headers may be used */
1306 vector
<FileLocation
> rpcDependencies
;
1307 GetRpcHeaderDependencies ( rpcDependencies
);
1308 if ( rpcDependencies
.size () > 0 )
1309 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1311 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1315 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1317 for ( size_t i
= 0; i
< module
.project
.non_if_data
.properties
.size (); i
++ )
1319 const Property
& property
= *module
.project
.non_if_data
.properties
[i
];
1320 if ( property
.name
== name
)
1321 return property
.value
;
1323 return string ( "" );
1326 /* caller needs to delete the returned object */
1328 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1330 string newname
= GetBasename ( base
->name
) + "_s.h";
1331 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1334 /* caller needs to delete the returned object */
1336 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1338 string newname
= GetBasename ( base
->name
) + "_c.h";
1339 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1342 /* caller needs to delete the returned object */
1344 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1346 string newname
= GetBasename ( base
->name
) + "_p.h";
1347 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1350 /* caller needs to delete the returned object */
1352 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1354 string newname
= GetBasename ( base
->name
) + ".h";
1355 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1358 /* caller needs to delete the returned object */
1360 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1362 string newname
= GetBasename ( base
->name
) + ".h";
1363 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1367 MingwModuleHandler::GenerateCommands (
1368 const CompilationUnit
& compilationUnit
,
1369 const string
& extraDependencies
)
1371 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1372 string extension
= GetExtension ( sourceFile
);
1373 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1382 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1383 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1384 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1385 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1386 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1387 { HostDontCare
, TypeDontCare
, ".spec", &winebuildRule
},
1388 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1389 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1390 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1391 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1392 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1393 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1394 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1395 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1396 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1397 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1398 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1399 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1400 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1401 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1404 Rule
*customRule
= NULL
;
1406 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1408 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= module
.host
)
1410 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1412 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1414 customRule
= rules
[i
].rule
;
1418 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1420 GenerateGccCommand ( &sourceFile
,
1422 GetCompilationUnitDependencies ( compilationUnit
) + GetExtraDependencies ( &sourceFile
) + extraDependencies
);
1424 else if ( customRule
)
1425 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1428 throw InvalidOperationException ( __FILE__
,
1430 "Unsupported filename extension '%s' in file '%s'",
1432 backend
->GetFullName ( sourceFile
).c_str () );
1437 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1439 fprintf ( fMakefile
,
1440 "ifeq ($(ROS_BUILDMAP),full)\n" );
1442 FileLocation
mapFilename ( OutputDirectory
,
1443 module
.output
->relative_path
,
1444 GetBasename ( module
.output
->name
) + ".map" );
1445 CLEAN_FILE ( mapFilename
);
1447 fprintf ( fMakefile
,
1448 "\t$(ECHO_OBJDUMP)\n" );
1449 fprintf ( fMakefile
,
1450 "\t$(Q)${objdump} -d -S %s > %s\n",
1451 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1452 backend
->GetFullName ( mapFilename
).c_str () );
1454 fprintf ( fMakefile
,
1456 fprintf ( fMakefile
,
1457 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1459 fprintf ( fMakefile
,
1461 fprintf ( fMakefile
,
1462 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1463 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1464 backend
->GetFullName ( mapFilename
).c_str () );
1466 fprintf ( fMakefile
,
1469 fprintf ( fMakefile
,
1474 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1476 fprintf ( fMakefile
,
1477 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1479 FileLocation
nostripFilename ( OutputDirectory
,
1480 module
.output
->relative_path
,
1481 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1482 CLEAN_FILE ( nostripFilename
);
1484 OutputCopyCommand ( *module
.output
, nostripFilename
);
1486 fprintf ( fMakefile
,
1491 MergeStringVector ( const Backend
* backend
,
1492 const vector
<FileLocation
>& input
,
1493 vector
<string
>& output
)
1497 int wrap_count
= -1;
1498 for ( size_t i
= 0; i
< input
.size (); i
++ )
1500 if ( wrap_count
++ == wrap_at
)
1502 output
.push_back ( s
);
1506 else if ( s
.size () > 0)
1508 s
+= backend
->GetFullName ( input
[i
] );
1510 if ( s
.length () > 0 )
1511 output
.push_back ( s
);
1515 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1516 vector
<FileLocation
>& objectFiles
) const
1518 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1520 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1521 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1522 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1523 objectFiles
.push_back ( *object_file
);
1529 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1531 if ( backend
->configuration
.CleanAsYouGo
)
1533 vector
<FileLocation
> objectFiles
;
1534 GetObjectsVector ( module
.non_if_data
,
1536 vector
<string
> lines
;
1537 MergeStringVector ( backend
,
1540 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1542 fprintf ( fMakefile
,
1543 "\t-@${rm} %s 2>$(NUL)\n",
1544 lines
[i
].c_str () );
1550 MingwModuleHandler::GenerateRunRsymCode () const
1552 fprintf ( fMakefile
,
1553 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1554 fprintf ( fMakefile
,
1555 "\t$(ECHO_RSYM)\n" );
1556 fprintf ( fMakefile
,
1557 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1558 fprintf ( fMakefile
,
1563 MingwModuleHandler::GenerateRunStripCode () const
1565 fprintf ( fMakefile
,
1566 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1567 fprintf ( fMakefile
,
1568 "\t$(ECHO_STRIP)\n" );
1569 fprintf ( fMakefile
,
1570 "\t${strip} -s -x -X $@\n\n" );
1571 fprintf ( fMakefile
,
1576 MingwModuleHandler::GenerateLinkerCommand (
1577 const string
& dependencies
,
1578 const string
& linkerParameters
,
1579 const string
& pefixupParameters
)
1581 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1582 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1583 string linker
= "${ld}";
1584 string objectsMacro
= GetObjectsMacro ( module
);
1585 string libsMacro
= GetLibsMacro ();
1587 string
target_macro ( GetTargetMacro ( module
) );
1588 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1590 string linkerScriptArgument
;
1591 if ( module
.linkerScript
!= NULL
)
1592 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1594 linkerScriptArgument
= "";
1596 fprintf ( fMakefile
,
1597 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1598 target_macro
.c_str (),
1599 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1600 dependencies
.c_str (),
1601 target_folder
.c_str () );
1602 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1603 string
targetName ( module
.output
->name
);
1605 /* HACK: if we have C++ in kernel, link it with some user mode dlls (kernel32 + msvcrt) ... */
1606 static const string libsCppKernel
= " '$(shell ${TARGET_CC} -print-file-name=libkernel32.a)' '$(shell ${TARGET_CC} -print-file-name=libmsvcrt.a)'";
1608 if ( !module
.HasImportLibrary() )
1610 fprintf ( fMakefile
,
1611 "\t%s %s%s %s %s%s%s %s -o %s\n",
1613 linkerParameters
.c_str (),
1614 linkerScriptArgument
.c_str (),
1615 objectsMacro
.c_str (),
1616 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1617 module
.cplusplus
&& (module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
) ? libsCppKernel
.c_str () : "",
1619 GetLinkerMacro ().c_str (),
1620 target_macro
.c_str () );
1624 FileLocation
temp_exp ( TemporaryDirectory
,
1626 module
.name
+ ".temp.exp" );
1627 CLEAN_FILE ( temp_exp
);
1629 fprintf ( fMakefile
,
1630 "\t${dlltool} --dllname %s --def %s --output-exp %s%s%s\n",
1631 targetName
.c_str (),
1632 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1633 backend
->GetFullName ( temp_exp
).c_str (),
1634 module
.mangledSymbols
? "" : " --kill-at",
1635 module
.underscoreSymbols
? " --add-underscore" : "" );
1637 fprintf ( fMakefile
,
1638 "\t%s %s%s %s %s %s%s%s %s -o %s\n",
1640 linkerParameters
.c_str (),
1641 linkerScriptArgument
.c_str (),
1642 backend
->GetFullName ( temp_exp
).c_str (),
1643 objectsMacro
.c_str (),
1644 module
.cplusplus
? "$(PROJECT_LPPFLAGS) " : "",
1645 module
.cplusplus
&& (module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
) ? libsCppKernel
.c_str () : "",
1647 GetLinkerMacro ().c_str (),
1648 target_macro
.c_str () );
1650 fprintf ( fMakefile
,
1651 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1652 target_macro
.c_str (),
1653 pefixupParameters
.c_str() );
1655 fprintf ( fMakefile
,
1656 "\t-@${rm} %s 2>$(NUL)\n",
1657 backend
->GetFullName ( temp_exp
).c_str () );
1660 GenerateBuildMapCode ();
1661 GenerateBuildNonSymbolStrippedCode ();
1662 GenerateRunRsymCode ();
1663 GenerateRunStripCode ();
1664 GenerateCleanObjectsAsYouGoCode ();
1666 if ( definitionFilename
)
1667 delete definitionFilename
;
1672 MingwModuleHandler::GeneratePhonyTarget() const
1674 string
targetMacro ( GetTargetMacro ( module
) );
1675 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1677 fprintf ( fMakefile
,
1679 targetMacro
.c_str ());
1680 fprintf ( fMakefile
, "%s: | %s\n",
1681 targetMacro
.c_str (),
1682 backend
->GetFullPath ( *target_file
).c_str () );
1688 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1691 string moduleDependencies
;
1693 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1694 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1696 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1697 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1698 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1699 if ( GetExtension ( *objectFilename
) == ".h" )
1700 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1701 else if ( GetExtension ( *objectFilename
) == ".rc" )
1702 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1703 delete objectFilename
;
1706 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1708 GenerateCommands ( *compilationUnits
[i
],
1709 moduleDependencies
);
1710 fprintf ( fMakefile
,
1714 const vector
<If
*>& ifs
= data
.ifs
;
1715 for ( i
= 0; i
< ifs
.size(); i
++ )
1717 GenerateObjectFileTargets ( ifs
[i
]->data
);
1720 vector
<CompilationUnit
*> sourceCompilationUnits
;
1721 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1722 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1724 GenerateCommands ( *sourceCompilationUnits
[i
],
1725 moduleDependencies
);
1727 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1731 MingwModuleHandler::GenerateObjectFileTargets ()
1733 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1737 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1738 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1740 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1741 CLEAN_FILE ( *pchFilename
);
1742 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1743 /* WIDL generated headers may be used */
1744 vector
<FileLocation
> rpcDependencies
;
1745 GetRpcHeaderDependencies ( rpcDependencies
);
1746 if ( rpcDependencies
.size () > 0 )
1747 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1748 fprintf ( fMakefile
,
1750 backend
->GetFullName ( *pchFilename
).c_str(),
1751 dependencies
.c_str(),
1752 backend
->GetFullPath ( *pchFilename
).c_str() );
1753 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1754 fprintf ( fMakefile
,
1755 "\t%s -o %s %s -g %s\n\n",
1756 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1757 backend
->GetFullName ( *pchFilename
).c_str(),
1758 cflagsMacro
.c_str(),
1759 backend
->GetFullName ( baseHeaderFile
).c_str() );
1763 GenerateObjectFileTargets ( module
.non_if_data
);
1764 fprintf ( fMakefile
, "\n" );
1767 /* caller needs to delete the returned object */
1769 MingwModuleHandler::GenerateArchiveTarget ()
1771 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1772 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1774 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1776 if ( IsStaticLibrary ( module
) && definitionFilename
)
1778 fprintf ( fMakefile
,
1779 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1780 module
.importLibrary
->dllname
.c_str (),
1781 backend
->GetFullName ( *definitionFilename
).c_str (),
1782 module
.mangledSymbols
? "" : " --kill-at",
1783 module
.underscoreSymbols
? " --add-underscore" : "" );
1786 if ( definitionFilename
)
1787 delete definitionFilename
;
1789 if(module
.type
== HostStaticLibrary
)
1790 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1792 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1794 GenerateCleanObjectsAsYouGoCode ();
1796 fprintf ( fMakefile
, "\n" );
1798 return archiveFilename
;
1802 MingwModuleHandler::GetCFlagsMacro () const
1804 return ssprintf ( "$(%s_CFLAGS)",
1805 module
.name
.c_str () );
1809 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1811 return ssprintf ( "$(%s_OBJS)",
1812 module
.name
.c_str () );
1816 MingwModuleHandler::GetLinkingDependenciesMacro () const
1818 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1822 MingwModuleHandler::GetLibsMacro () const
1824 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1828 MingwModuleHandler::GetLinkerMacro () const
1830 return ssprintf ( "$(%s_LFLAGS)",
1831 module
.name
.c_str () );
1835 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1837 if ( ReferenceObjects ( module
) )
1838 return GetObjectsMacro ( module
);
1841 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1842 string target
= backend
->GetFullName ( *target_file
).c_str ();
1849 MingwModuleHandler::GenerateSourceMacro ()
1851 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1853 GenerateSourceMacros (
1855 module
.non_if_data
);
1857 // future references to the macro will be to get its values
1858 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1862 MingwModuleHandler::GenerateObjectMacro ()
1864 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1866 GenerateObjectMacros (
1868 module
.non_if_data
);
1870 // future references to the macro will be to get its values
1871 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1875 MingwModuleHandler::GenerateTargetMacro ()
1877 fprintf ( fMakefile
,
1879 GetTargetMacro ( module
, false ).c_str (),
1880 GetModuleTargets ( module
).c_str () );
1884 MingwModuleHandler::GetRpcHeaderDependencies (
1885 vector
<FileLocation
>& dependencies
) const
1887 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1889 Library
& library
= *module
.non_if_data
.libraries
[i
];
1890 if ( library
.importedModule
->type
== RpcServer
||
1891 library
.importedModule
->type
== RpcClient
||
1892 library
.importedModule
->type
== RpcProxy
||
1893 library
.importedModule
->type
== IdlHeader
)
1895 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1897 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1898 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1899 string extension
= GetExtension ( sourceFile
);
1900 if ( extension
== ".idl" || extension
== ".IDL" )
1902 string basename
= GetBasename ( sourceFile
.name
);
1903 if ( library
.importedModule
->type
== RpcServer
)
1905 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1906 dependencies
.push_back ( *header
);
1909 if ( library
.importedModule
->type
== RpcClient
)
1911 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1912 dependencies
.push_back ( *header
);
1915 if ( library
.importedModule
->type
== RpcProxy
)
1917 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1918 dependencies
.push_back ( *header
);
1921 if ( library
.importedModule
->type
== IdlHeader
)
1923 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1924 dependencies
.push_back ( *header
);
1934 MingwModuleHandler::GenerateOtherMacros ()
1936 set
<const Define
*> used_defs
;
1938 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1939 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1940 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1941 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1942 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1943 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1944 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1949 &module
.linkerFlags
,
1952 if ( module
.host
== HostFalse
)
1956 module
.project
.non_if_data
,
1961 vector
<FileLocation
> s
;
1962 if ( module
.importLibrary
)
1964 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
1965 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
1967 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1968 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1969 string extension
= GetExtension ( sourceFile
);
1970 if ( extension
== ".spec" || extension
== ".SPEC" )
1971 GetSpecObjectDependencies ( s
, &sourceFile
);
1974 if ( s
.size () > 0 )
1979 linkDepsMacro
.c_str() );
1980 for ( size_t i
= 0; i
< s
.size(); i
++ )
1981 fprintf ( fMakefile
,
1983 backend
->GetFullName ( s
[i
] ).c_str () );
1984 fprintf ( fMakefile
, "\n" );
1987 string globalCflags
= "";
1988 if ( module
.host
== HostFalse
)
1989 globalCflags
+= " $(PROJECT_CFLAGS)";
1991 globalCflags
+= " -Wall -Wpointer-arith -D__REACTOS__";
1992 globalCflags
+= " -g";
1993 if ( backend
->usePipe
)
1994 globalCflags
+= " -pipe";
1995 if ( !module
.allowWarnings
)
1996 globalCflags
+= " -Werror";
1997 if ( module
.host
== HostTrue
)
1999 if ( module
.cplusplus
)
2000 globalCflags
+= " $(HOST_CPPFLAGS)";
2002 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
2006 if ( module
.cplusplus
)
2008 // HACK: use host headers when building C++
2009 globalCflags
+= " $(HOST_CPPFLAGS)";
2012 globalCflags
+= " -nostdinc";
2015 // Always force disabling of sibling calls optimisation for GCC
2016 // (TODO: Move to version-specific once this bug is fixed in GCC)
2017 globalCflags
+= " -fno-optimize-sibling-calls";
2022 cflagsMacro
.c_str (),
2023 globalCflags
.c_str () );
2025 if ( module
.host
== HostFalse
)
2029 "%s += $(PROJECT_RCFLAGS)\n",
2030 windresflagsMacro
.c_str () );
2034 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
2035 widlflagsMacro
.c_str (),
2036 module
.output
->relative_path
.c_str () );
2040 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
2041 module
.name
.c_str () );
2047 "%s_LFLAGS += $(HOST_LFLAGS)\n",
2048 module
.name
.c_str () );
2054 linkDepsMacro
.c_str (),
2055 libsMacro
.c_str () );
2057 string cflags
= TypeSpecificCFlags();
2058 if ( cflags
.size() > 0 )
2060 fprintf ( fMakefile
,
2062 cflagsMacro
.c_str (),
2066 string nasmflags
= TypeSpecificNasmFlags();
2067 if ( nasmflags
.size () > 0 )
2069 fprintf ( fMakefile
,
2071 nasmflagsMacro
.c_str (),
2072 nasmflags
.c_str () );
2075 string linkerflags
= TypeSpecificLinkerFlags();
2076 if ( linkerflags
.size() > 0 )
2078 fprintf ( fMakefile
,
2080 linkerflagsMacro
.c_str (),
2081 linkerflags
.c_str () );
2084 if ( IsStaticLibrary ( module
) && module
.isStartupLib
)
2086 fprintf ( fMakefile
,
2087 "%s += -Wno-main\n\n",
2088 cflagsMacro
.c_str () );
2091 fprintf ( fMakefile
, "\n\n" );
2093 // future references to the macros will be to get their values
2094 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2095 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2096 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2100 MingwModuleHandler::GenerateRules ()
2102 string targetMacro
= GetTargetMacro ( module
);
2103 //CLEAN_FILE ( targetMacro );
2104 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2106 // generate phony target for module name
2107 fprintf ( fMakefile
, ".PHONY: %s\n",
2108 module
.name
.c_str () );
2109 string dependencies
= GetTargetMacro ( module
);
2110 if ( module
.type
== Test
)
2111 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2112 fprintf ( fMakefile
, "%s: %s\n\n",
2113 module
.name
.c_str (),
2114 dependencies
.c_str () );
2115 if ( module
.type
== Test
)
2117 fprintf ( fMakefile
,
2119 targetMacro
.c_str ());
2122 if ( !ReferenceObjects ( module
) )
2124 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2128 GenerateObjectFileTargets ();
2132 MingwModuleHandler::GetInvocationDependencies (
2133 const Module
& module
,
2134 string_list
& dependencies
)
2136 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2138 Invoke
& invoke
= *module
.invocations
[i
];
2139 if ( invoke
.invokeModule
== &module
)
2140 /* Protect against circular dependencies */
2142 invoke
.GetTargets ( dependencies
);
2147 MingwModuleHandler::GenerateInvocations () const
2149 if ( module
.invocations
.size () == 0 )
2152 size_t iend
= module
.invocations
.size ();
2153 for ( size_t i
= 0; i
< iend
; i
++ )
2155 const Invoke
& invoke
= *module
.invocations
[i
];
2157 if ( invoke
.invokeModule
->type
!= BuildTool
)
2159 throw XMLInvalidBuildFileException (
2160 module
.node
.location
,
2161 "Only modules of type buildtool can be invoked." );
2164 string invokeTarget
= module
.GetInvocationTarget ( i
);
2165 string_list invoke_targets
;
2166 assert ( invoke_targets
.size() );
2167 invoke
.GetTargets ( invoke_targets
);
2168 fprintf ( fMakefile
,
2170 invokeTarget
.c_str () );
2171 fprintf ( fMakefile
,
2173 invokeTarget
.c_str () );
2174 size_t j
, jend
= invoke_targets
.size();
2175 for ( j
= 0; j
< jend
; j
++ )
2177 fprintf ( fMakefile
,
2179 invoke_targets
[i
].c_str () );
2181 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2182 for ( j
= 1; j
< jend
; j
++ )
2183 fprintf ( fMakefile
,
2185 invoke_targets
[i
].c_str () );
2186 fprintf ( fMakefile
,
2188 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2189 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2190 fprintf ( fMakefile
,
2192 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2193 invoke
.GetParameters ().c_str () );
2198 MingwModuleHandler::GetPreconditionDependenciesName () const
2200 return module
.name
+ "_precondition";
2204 MingwModuleHandler::GetDefaultDependencies (
2205 string_list
& dependencies
) const
2207 /* Avoid circular dependency */
2208 if ( module
.host
== HostTrue
)
2211 if (module
.name
!= "psdk" &&
2212 module
.name
!= "dxsdk")
2214 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2215 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2218 if (module
.name
!= "errcodes" &&
2219 module
.name
!= "bugcodes" &&
2220 module
.name
!= "ntstatus")
2222 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2223 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2224 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2227 ///* Check if any dependent library relies on the generated headers */
2228 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2230 // const Module& m = *module.project.modules[i];
2231 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2233 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2234 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2235 // string extension = GetExtension ( sourceFile );
2236 // if (extension == ".mc" || extension == ".MC" )
2238 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2239 // dependencies.push_back ( dependency );
2246 MingwModuleHandler::GeneratePreconditionDependencies ()
2248 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2249 string_list dependencies
;
2250 GetDefaultDependencies ( dependencies
);
2251 GetModuleDependencies ( dependencies
);
2253 GetInvocationDependencies ( module
, dependencies
);
2255 if ( dependencies
.size() )
2257 fprintf ( fMakefile
,
2259 preconditionDependenciesName
.c_str () );
2260 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2261 fprintf ( fMakefile
,
2263 dependencies
[i
].c_str () );
2264 fprintf ( fMakefile
, "\n\n" );
2267 fprintf ( fMakefile
, "\n" );
2271 MingwModuleHandler::IsWineModule () const
2273 if ( module
.importLibrary
== NULL
)
2276 size_t index
= module
.importLibrary
->source
->name
.rfind ( ".spec.def" );
2277 return ( index
!= string::npos
);
2280 /* caller needs to delete the returned object */
2282 MingwModuleHandler::GetDefinitionFilename () const
2284 if ( module
.importLibrary
== NULL
)
2287 DirectoryLocation directory
;
2288 if ( IsWineModule () )
2289 directory
= IntermediateDirectory
;
2291 directory
= SourceDirectory
;
2293 return new FileLocation ( directory
,
2294 module
.importLibrary
->source
->relative_path
,
2295 module
.importLibrary
->source
->name
);
2299 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2301 if ( module
.importLibrary
!= NULL
)
2303 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2304 const FileLocation
*defFilename
= GetDefinitionFilename ();
2305 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2307 vector
<FileLocation
> deps
;
2308 GetDefinitionDependencies ( deps
);
2310 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
2312 fprintf ( fMakefile
, "%s:",
2313 backend
->GetFullName ( *library_target
).c_str () );
2317 fprintf ( fMakefile
, " %s",
2318 backend
->GetFullName ( *defFilename
).c_str () );
2321 size_t i
, iend
= deps
.size();
2322 for ( i
= 0; i
< iend
; i
++ )
2323 fprintf ( fMakefile
, " %s",
2324 backend
->GetFullName ( deps
[i
] ).c_str () );
2326 fprintf ( fMakefile
, " | %s\n",
2327 backend
->GetFullPath ( *library_target
).c_str () );
2329 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2331 fprintf ( fMakefile
,
2332 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2333 module
.output
->name
.c_str (),
2334 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2336 backend
->GetFullName ( *library_target
).c_str (),
2337 module
.mangledSymbols
? "" : " --kill-at",
2338 module
.underscoreSymbols
? " --add-underscore" : "" );
2342 delete library_target
;
2347 MingwModuleHandler::GetSpecObjectDependencies (
2348 vector
<FileLocation
>& dependencies
,
2349 const FileLocation
*file
) const
2351 string basename
= GetBasename ( file
->name
);
2353 FileLocation
defDependency ( IntermediateDirectory
,
2354 file
->relative_path
,
2355 basename
+ ".spec.def" );
2356 dependencies
.push_back ( defDependency
);
2358 FileLocation
stubsDependency ( IntermediateDirectory
,
2359 file
->relative_path
,
2360 basename
+ ".stubs.c" );
2361 dependencies
.push_back ( stubsDependency
);
2365 MingwModuleHandler::GetMcObjectDependencies (
2366 vector
<FileLocation
>& dependencies
,
2367 const FileLocation
*file
) const
2369 string basename
= GetBasename ( file
->name
);
2371 FileLocation
defDependency ( IntermediateDirectory
,
2374 dependencies
.push_back ( defDependency
);
2376 FileLocation
stubsDependency ( IntermediateDirectory
,
2377 file
->relative_path
,
2379 dependencies
.push_back ( stubsDependency
);
2383 MingwModuleHandler::GetWidlObjectDependencies (
2384 vector
<FileLocation
>& dependencies
,
2385 const FileLocation
*file
) const
2387 string basename
= GetBasename ( file
->name
);
2388 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2390 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2391 file
->relative_path
,
2392 basename
+ "_s.c" );
2393 dependencies
.push_back ( serverSourceDependency
);
2394 dependencies
.push_back ( *generatedHeaderFilename
);
2396 delete generatedHeaderFilename
;
2400 MingwModuleHandler::GetDefinitionDependencies (
2401 vector
<FileLocation
>& dependencies
) const
2403 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2404 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2406 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2407 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2408 string extension
= GetExtension ( sourceFile
);
2409 if ( extension
== ".spec" || extension
== ".SPEC" )
2410 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2411 if ( extension
== ".idl" || extension
== ".IDL" )
2413 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2414 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2419 enum DebugSupportType
2426 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2432 case DebugKernelMode
:
2433 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2437 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2444 module
.non_if_data
.libraries
.push_back(pLibrary
);
2447 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2448 : MingwModuleHandler ( module_
)
2453 MingwBuildToolModuleHandler::Process ()
2455 GenerateBuildToolModuleTarget ();
2459 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2461 string
targetMacro ( GetTargetMacro (module
) );
2462 string objectsMacro
= GetObjectsMacro ( module
);
2463 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2464 string libsMacro
= GetLibsMacro ();
2469 if ( module
.cplusplus
)
2470 linker
= "${host_gpp}";
2472 linker
= "${host_gcc}";
2474 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2475 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2476 targetMacro
.c_str (),
2477 objectsMacro
.c_str (),
2478 linkDepsMacro
.c_str (),
2479 backend
->GetFullPath ( *target_file
).c_str () );
2480 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2481 fprintf ( fMakefile
,
2482 "\t%s %s -o $@ %s %s\n\n",
2484 GetLinkerMacro ().c_str (),
2485 objectsMacro
.c_str (),
2486 libsMacro
.c_str () );
2492 MingwKernelModuleHandler::MingwKernelModuleHandler (
2493 const Module
& module_
)
2495 : MingwModuleHandler ( module_
)
2500 MingwKernelModuleHandler::Process ()
2502 GenerateKernelModuleTarget ();
2506 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2508 string
targetMacro ( GetTargetMacro ( module
) );
2509 string workingDirectory
= GetWorkingDirectory ( );
2510 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2512 GenerateImportLibraryTargetIfNeeded ();
2514 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2518 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2520 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2521 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2522 module
.baseaddress
.c_str () );
2524 GenerateLinkerCommand ( dependencies
,
2525 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2530 GeneratePhonyTarget();
2535 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2536 const Module
& module_
)
2538 : MingwModuleHandler ( module_
)
2543 MingwStaticLibraryModuleHandler::Process ()
2545 GenerateStaticLibraryModuleTarget ();
2549 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2555 MingwHostStaticLibraryModuleHandler::MingwHostStaticLibraryModuleHandler (
2556 const Module
& module_
)
2558 : MingwModuleHandler ( module_
)
2563 MingwHostStaticLibraryModuleHandler::Process ()
2565 GenerateHostStaticLibraryModuleTarget ();
2569 MingwHostStaticLibraryModuleHandler::GenerateHostStaticLibraryModuleTarget ()
2575 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2576 const Module
& module_
)
2578 : MingwModuleHandler ( module_
)
2583 MingwObjectLibraryModuleHandler::Process ()
2585 GenerateObjectLibraryModuleTarget ();
2589 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2595 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2596 const Module
& module_
)
2598 : MingwModuleHandler ( module_
)
2602 MingwEmbeddedTypeLibModuleHandler::MingwEmbeddedTypeLibModuleHandler (
2603 const Module
& module_
)
2605 : MingwModuleHandler ( module_
)
2610 MingwEmbeddedTypeLibModuleHandler::Process ()
2617 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2619 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2623 MingwKernelModeDLLModuleHandler::Process ()
2625 GenerateKernelModeDLLModuleTarget ();
2629 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2631 string
targetMacro ( GetTargetMacro ( module
) );
2632 string workingDirectory
= GetWorkingDirectory ( );
2633 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2635 GenerateImportLibraryTargetIfNeeded ();
2637 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2641 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2643 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2644 module
.GetEntryPoint(true).c_str (),
2645 module
.baseaddress
.c_str () );
2646 GenerateLinkerCommand ( dependencies
,
2652 GeneratePhonyTarget();
2657 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2658 const Module
& module_
)
2660 : MingwModuleHandler ( module_
)
2665 MingwKernelModeDriverModuleHandler::AddImplicitLibraries ( Module
& module
)
2667 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2671 MingwKernelModeDriverModuleHandler::Process ()
2673 GenerateKernelModeDriverModuleTarget ();
2678 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2680 string
targetMacro ( GetTargetMacro (module
) );
2681 string workingDirectory
= GetWorkingDirectory ();
2682 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2684 GenerateImportLibraryTargetIfNeeded ();
2686 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2690 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2692 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2693 module
.GetEntryPoint(true).c_str (),
2694 module
.baseaddress
.c_str () );
2695 GenerateLinkerCommand ( dependencies
,
2701 GeneratePhonyTarget();
2706 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2707 const Module
& module_
)
2709 : MingwModuleHandler ( module_
)
2714 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2716 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2720 MingwNativeDLLModuleHandler::Process ()
2722 GenerateNativeDLLModuleTarget ();
2726 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2728 string
targetMacro ( GetTargetMacro (module
) );
2729 string workingDirectory
= GetWorkingDirectory ( );
2730 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2732 GenerateImportLibraryTargetIfNeeded ();
2734 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2738 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2740 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2741 module
.GetEntryPoint(true).c_str (),
2742 module
.baseaddress
.c_str () );
2743 GenerateLinkerCommand ( dependencies
,
2749 GeneratePhonyTarget();
2754 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2755 const Module
& module_
)
2757 : MingwModuleHandler ( module_
)
2762 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2764 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2768 MingwNativeCUIModuleHandler::Process ()
2770 GenerateNativeCUIModuleTarget ();
2774 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2776 string
targetMacro ( GetTargetMacro (module
) );
2777 string workingDirectory
= GetWorkingDirectory ( );
2778 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2780 GenerateImportLibraryTargetIfNeeded ();
2782 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2786 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2788 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2789 module
.GetEntryPoint(true).c_str (),
2790 module
.baseaddress
.c_str () );
2791 GenerateLinkerCommand ( dependencies
,
2797 GeneratePhonyTarget();
2802 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2803 const Module
& module_
)
2805 : MingwModuleHandler ( module_
)
2809 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2810 const Module
& module_
)
2812 : MingwModuleHandler ( module_
)
2817 LinksToCrt( Module
&module
)
2819 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
2821 Library
& library
= *module
.non_if_data
.libraries
[i
];
2822 if ( library
.name
== "libcntpr" || library
.name
== "crt" )
2829 MingwAddImplicitLibraries( Module
&module
)
2834 if ( module
.type
!= Win32DLL
2835 && module
.type
!= Win32OCX
2836 && module
.type
!= Win32CUI
2837 && module
.type
!= Win32GUI
2838 && module
.type
!= Win32SCR
)
2840 // no implicit libraries
2844 links_to_crt
= LinksToCrt ( module
);
2846 if ( !module
.isDefaultEntryPoint
)
2848 if ( module
.GetEntryPoint(false) == "0" )
2850 if ( !links_to_crt
)
2852 pLibrary
= new Library ( module
, "mingw_common" );
2853 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() , pLibrary
);
2855 pLibrary
= new Library ( module
, "msvcrt" );
2856 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2857 links_to_crt
= true;
2863 if ( module
.IsDLL () )
2865 //pLibrary = new Library ( module, "__mingw_dllmain" );
2866 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2870 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2871 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2874 pLibrary
= new Library ( module
, "mingw_common" );
2875 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin() + 1, pLibrary
);
2877 if ( !links_to_crt
)
2879 // always link in msvcrt to get the basic routines
2880 pLibrary
= new Library ( module
, "msvcrt" );
2881 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2886 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2888 MingwAddImplicitLibraries ( module
);
2889 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2893 MingwWin32DLLModuleHandler::Process ()
2895 GenerateWin32DLLModuleTarget ();
2899 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2901 string
targetMacro ( GetTargetMacro (module
) );
2902 string workingDirectory
= GetWorkingDirectory ( );
2903 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2905 GenerateImportLibraryTargetIfNeeded ();
2907 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2911 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2913 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2914 module
.GetEntryPoint(true).c_str (),
2915 module
.baseaddress
.c_str () );
2916 GenerateLinkerCommand ( dependencies
,
2922 GeneratePhonyTarget();
2928 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2930 MingwAddImplicitLibraries ( module
);
2931 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2935 MingwWin32OCXModuleHandler::Process ()
2937 GenerateWin32OCXModuleTarget ();
2941 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2943 string
targetMacro ( GetTargetMacro (module
) );
2944 string workingDirectory
= GetWorkingDirectory ( );
2945 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2947 GenerateImportLibraryTargetIfNeeded ();
2949 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2953 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2955 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2956 module
.GetEntryPoint(true).c_str (),
2957 module
.baseaddress
.c_str () );
2958 GenerateLinkerCommand ( dependencies
,
2964 GeneratePhonyTarget();
2969 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2970 const Module
& module_
)
2972 : MingwModuleHandler ( module_
)
2977 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2979 MingwAddImplicitLibraries ( module
);
2980 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2984 MingwWin32CUIModuleHandler::Process ()
2986 GenerateWin32CUIModuleTarget ();
2990 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2992 string
targetMacro ( GetTargetMacro (module
) );
2993 string workingDirectory
= GetWorkingDirectory ( );
2994 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2996 GenerateImportLibraryTargetIfNeeded ();
2998 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3002 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3004 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3005 module
.GetEntryPoint(true).c_str (),
3006 module
.baseaddress
.c_str () );
3007 GenerateLinkerCommand ( dependencies
,
3013 GeneratePhonyTarget();
3018 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
3019 const Module
& module_
)
3021 : MingwModuleHandler ( module_
)
3026 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
3028 MingwAddImplicitLibraries ( module
);
3029 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
3033 MingwWin32GUIModuleHandler::Process ()
3035 GenerateWin32GUIModuleTarget ();
3039 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
3041 string
targetMacro ( GetTargetMacro (module
) );
3042 string workingDirectory
= GetWorkingDirectory ( );
3043 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3045 GenerateImportLibraryTargetIfNeeded ();
3047 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3051 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3053 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3054 module
.GetEntryPoint(true).c_str (),
3055 module
.baseaddress
.c_str () );
3056 GenerateLinkerCommand ( dependencies
,
3062 GeneratePhonyTarget();
3067 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
3068 const Module
& module_
)
3070 : MingwModuleHandler ( module_
)
3075 MingwBootLoaderModuleHandler::Process ()
3077 GenerateBootLoaderModuleTarget ();
3081 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
3083 string
targetName ( module
.output
->name
);
3084 string
targetMacro ( GetTargetMacro (module
) );
3085 string workingDirectory
= GetWorkingDirectory ();
3086 FileLocation
junk_tmp ( TemporaryDirectory
,
3088 module
.name
+ ".junk.tmp" );
3089 CLEAN_FILE ( junk_tmp
);
3090 string objectsMacro
= GetObjectsMacro ( module
);
3091 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3092 string libsMacro
= GetLibsMacro ();
3096 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3097 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3098 targetMacro
.c_str (),
3099 objectsMacro
.c_str (),
3100 linkDepsMacro
.c_str (),
3101 backend
->GetFullPath ( *target_file
).c_str () );
3103 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
3105 if (Environment::GetArch() == "arm")
3107 fprintf ( fMakefile
,
3108 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
3109 backend
->GetFullName ( junk_tmp
).c_str (),
3110 objectsMacro
.c_str (),
3111 linkDepsMacro
.c_str (),
3112 GetLinkerMacro ().c_str ());
3116 fprintf ( fMakefile
,
3117 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
3118 backend
->GetFullName ( junk_tmp
).c_str (),
3119 objectsMacro
.c_str (),
3120 linkDepsMacro
.c_str (),
3121 GetLinkerMacro ().c_str ());
3123 fprintf ( fMakefile
,
3124 "\t${objcopy} -O binary %s $@\n",
3125 backend
->GetFullName ( junk_tmp
).c_str () );
3126 GenerateBuildMapCode ( &junk_tmp
);
3127 fprintf ( fMakefile
,
3128 "\t-@${rm} %s 2>$(NUL)\n",
3129 backend
->GetFullName ( junk_tmp
).c_str () );
3135 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
3136 const Module
& module_
)
3138 : MingwModuleHandler ( module_
)
3143 MingwBootSectorModuleHandler::Process ()
3145 GenerateBootSectorModuleTarget ();
3149 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
3151 string objectsMacro
= GetObjectsMacro ( module
);
3155 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3156 module
.name
.c_str ());
3157 fprintf ( fMakefile
,
3159 module
.name
.c_str (),
3160 objectsMacro
.c_str () );
3164 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
3165 const Module
& module_
)
3166 : MingwModuleHandler ( module_
)
3171 MingwBootProgramModuleHandler::Process ()
3173 GenerateBootProgramModuleTarget ();
3177 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
3179 string
targetName ( module
.output
->name
);
3180 string
targetMacro ( GetTargetMacro (module
) );
3181 string workingDirectory
= GetWorkingDirectory ();
3182 FileLocation
junk_tmp ( TemporaryDirectory
,
3184 module
.name
+ ".junk.tmp" );
3185 FileLocation
junk_elf ( TemporaryDirectory
,
3187 module
.name
+ ".junk.elf" );
3188 FileLocation
junk_cpy ( TemporaryDirectory
,
3190 module
.name
+ ".junk.elf" );
3191 CLEAN_FILE ( junk_tmp
);
3192 CLEAN_FILE ( junk_elf
);
3193 CLEAN_FILE ( junk_cpy
);
3194 string objectsMacro
= GetObjectsMacro ( module
);
3195 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3196 string libsMacro
= GetLibsMacro ();
3197 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
3201 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3202 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
3203 targetMacro
.c_str (),
3204 objectsMacro
.c_str (),
3205 linkDepsMacro
.c_str (),
3206 payload
->name
.c_str (),
3207 backend
->GetFullPath ( *target_file
).c_str () );
3209 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3211 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3212 module
.buildtype
.c_str (),
3213 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3214 backend
->GetFullName ( junk_cpy
).c_str () );
3216 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3217 module
.buildtype
.c_str (),
3218 backend
->GetFullName ( junk_cpy
).c_str (),
3219 backend
->GetFullName ( junk_tmp
).c_str () );
3221 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3222 module
.buildtype
.c_str (),
3223 linkDepsMacro
.c_str (),
3224 backend
->GetFullName ( junk_tmp
).c_str (),
3225 backend
->GetFullName ( junk_elf
).c_str () );
3227 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3228 module
.buildtype
.c_str (),
3229 backend
->GetFullName ( junk_elf
).c_str (),
3230 backend
->GetFullName ( *module
.output
) .c_str () );
3232 fprintf ( fMakefile
,
3233 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3234 backend
->GetFullName ( junk_tmp
).c_str (),
3235 backend
->GetFullName ( junk_elf
).c_str (),
3236 backend
->GetFullName ( junk_cpy
).c_str () );
3242 MingwIsoModuleHandler::MingwIsoModuleHandler (
3243 const Module
& module_
)
3245 : MingwModuleHandler ( module_
)
3250 MingwIsoModuleHandler::Process ()
3252 GenerateIsoModuleTarget ();
3256 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3257 const string
& bootcdDirectory
)
3259 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3261 const Module
& m
= *module
.project
.modules
[i
];
3264 if ( m
.bootstrap
!= NULL
)
3266 FileLocation
targetFile ( OutputDirectory
,
3267 m
.bootstrap
->base
.length () > 0
3268 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3270 m
.bootstrap
->nameoncd
);
3271 OutputCopyCommand ( *m
.output
, targetFile
);
3277 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3278 const string
& bootcdDirectory
)
3280 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3282 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3283 FileLocation
targetFile ( OutputDirectory
,
3284 cdfile
.target
->relative_path
.length () > 0
3285 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3287 cdfile
.target
->name
);
3288 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3293 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3294 const string
& bootcdDirectory
)
3296 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3298 const Module
& m
= *module
.project
.modules
[i
];
3301 if ( m
.bootstrap
!= NULL
)
3303 FileLocation
targetDirectory ( OutputDirectory
,
3304 m
.bootstrap
->base
.length () > 0
3305 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3308 out
.push_back ( targetDirectory
);
3314 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3315 const string
& bootcdDirectory
)
3317 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3319 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3320 FileLocation
targetDirectory ( OutputDirectory
,
3321 cdfile
.target
->relative_path
.length () > 0
3322 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3325 out
.push_back( targetDirectory
);
3330 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3331 const string
& bootcdDirectory
)
3333 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3334 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3338 MingwIsoModuleHandler::GetBootstrapCdFiles (
3339 vector
<FileLocation
>& out
) const
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 out
.push_back ( *m
.output
);
3354 MingwIsoModuleHandler::GetNonModuleCdFiles (
3355 vector
<FileLocation
>& out
) const
3357 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3359 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3360 out
.push_back ( *cdfile
.source
);
3365 MingwIsoModuleHandler::GetCdFiles (
3366 vector
<FileLocation
>& out
) const
3368 GetBootstrapCdFiles ( out
);
3369 GetNonModuleCdFiles ( out
);
3373 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3375 string bootcdDirectory
= "cd";
3376 FileLocation
bootcd ( OutputDirectory
,
3379 FileLocation
bootcdReactos ( OutputDirectory
,
3380 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3382 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3383 vector
<FileLocation
> vCdDirectories
;
3386 FileLocation
srcunattend ( SourceDirectory
,
3387 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3389 FileLocation
tarunattend ( bootcdReactos
.directory
,
3390 bootcdReactos
.relative_path
,
3392 if (module
.type
== IsoRegTest
)
3393 vSourceFiles
.push_back ( srcunattend
);
3396 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3400 throw InvalidOperationException ( module
.node
.location
.c_str(),
3402 "Invalid bootsector. module '%s' requires <bootsector>",
3403 module
.name
.c_str ());
3406 const FileLocation
*isoboot
= bootModule
->output
;
3407 vSourceFiles
.push_back ( *isoboot
);
3409 // prepare reactos.dff and reactos.inf
3410 FileLocation
reactosDff ( SourceDirectory
,
3411 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3413 FileLocation
reactosInf ( bootcdReactos
.directory
,
3414 bootcdReactos
.relative_path
,
3417 vSourceFiles
.push_back ( reactosDff
);
3420 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3421 Iso/LiveIso outputs are generated in code base root
3423 string IsoName
= module
.output
->name
;
3425 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3428 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3429 GetCdFiles ( vCdFiles
);
3430 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3431 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3433 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3434 module
.name
.c_str ());
3435 fprintf ( fMakefile
,
3436 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3437 module
.name
.c_str (),
3438 backend
->GetFullName ( *isoboot
).c_str (),
3439 sourceFiles
.c_str (),
3441 cdDirectories
.c_str () );
3442 fprintf ( fMakefile
,
3443 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3444 backend
->GetFullName ( reactosDff
).c_str (),
3445 backend
->GetFullPath ( bootcdReactos
).c_str () );
3446 fprintf ( fMakefile
,
3447 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3448 backend
->GetFullName ( reactosDff
).c_str (),
3449 backend
->GetFullName ( reactosInf
).c_str (),
3450 backend
->GetFullPath ( bootcdReactos
).c_str ());
3451 fprintf ( fMakefile
,
3452 "\t-@${rm} %s 2>$(NUL)\n",
3453 backend
->GetFullName ( reactosInf
).c_str () );
3454 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3455 OutputCdfileCopyCommands ( bootcdDirectory
);
3457 if (module
.type
== IsoRegTest
)
3458 OutputCopyCommand ( srcunattend
, tarunattend
);
3460 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3461 fprintf ( fMakefile
,
3462 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3463 backend
->GetFullName ( *isoboot
).c_str (),
3464 backend
->GetFullPath ( bootcd
).c_str (),
3466 fprintf ( fMakefile
,
3471 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3472 const Module
& module_
)
3474 : MingwModuleHandler ( module_
)
3479 MingwLiveIsoModuleHandler::Process ()
3481 GenerateLiveIsoModuleTarget ();
3485 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3487 FileLocation
dir ( OutputDirectory
,
3490 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3494 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3495 string
& reactosDirectory
)
3497 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
3499 const Module
& m
= *module
.project
.modules
[i
];
3504 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3505 FileLocation
destination ( OutputDirectory
,
3506 m
.install
->relative_path
.length () > 0
3507 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3508 : livecdDirectory
+ sSep
+ reactosDirectory
,
3510 OutputCopyCommand ( *aliasedModule
.output
,
3517 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3518 string
& reactosDirectory
)
3520 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3522 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3523 FileLocation
target ( OutputDirectory
,
3524 installfile
.target
->relative_path
.length () > 0
3525 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3526 : livecdDirectory
+ sSep
+ reactosDirectory
,
3527 installfile
.target
->name
);
3528 OutputCopyCommand ( *installfile
.source
, target
);
3533 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3535 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3536 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3537 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3538 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3539 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3540 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3542 FileLocation
livecdIni ( SourceDirectory
,
3543 "boot" + sSep
+ "bootdata",
3545 FileLocation
destination ( OutputDirectory
,
3548 OutputCopyCommand ( livecdIni
,
3553 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3555 FileLocation
freeldr ( OutputDirectory
,
3556 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3558 FileLocation
destination ( OutputDirectory
,
3559 livecdDirectory
+ sSep
+ "loader",
3561 OutputCopyCommand ( freeldr
,
3566 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3568 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3569 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3571 fprintf ( fMakefile
,
3572 "\t$(ECHO_MKHIVE)\n" );
3573 fprintf ( fMakefile
,
3574 "\t$(MKHIVE_TARGET) boot%cbootdata %s boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst.inf\n",
3575 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3576 cSep
, cSep
, cSep
, cSep
);
3580 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3582 string livecdDirectory
= module
.name
;
3583 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3588 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3592 throw InvalidOperationException ( module
.node
.location
.c_str(),
3594 "Invalid bootsector. module '%s' requires <bootsector>",
3595 module
.name
.c_str ());
3598 const FileLocation
*isoboot
= bootModule
->output
;
3601 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3602 Iso/LiveIso outputs are generated in code base root
3604 IsoName
= module
.output
->name
;
3606 string reactosDirectory
= "reactos";
3607 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3608 FileLocation
livecdReactos ( OutputDirectory
,
3609 livecdReactosNoFixup
,
3611 CLEAN_FILE ( livecdReactos
);
3613 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3614 module
.name
.c_str ());
3615 fprintf ( fMakefile
,
3616 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3617 module
.name
.c_str (),
3618 backend
->GetFullName ( *isoboot
) .c_str (),
3619 backend
->GetFullPath ( livecdReactos
).c_str () );
3620 OutputModuleCopyCommands ( livecdDirectory
,
3622 OutputNonModuleCopyCommands ( livecdDirectory
,
3624 OutputProfilesDirectoryCommands ( livecdDirectory
);
3625 OutputLoaderCommands ( livecdDirectory
);
3626 OutputRegistryCommands ( livecdDirectory
);
3627 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3628 fprintf ( fMakefile
,
3629 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3630 backend
->GetFullName( *isoboot
).c_str (),
3631 backend
->GetFullPath ( livecd
).c_str (),
3633 fprintf ( fMakefile
,
3638 MingwTestModuleHandler::MingwTestModuleHandler (
3639 const Module
& module_
)
3641 : MingwModuleHandler ( module_
)
3646 MingwTestModuleHandler::Process ()
3648 GenerateTestModuleTarget ();
3651 /* caller needs to delete the returned object */
3653 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3655 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3656 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3657 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3661 MingwTestModuleHandler::GenerateTestModuleTarget ()
3663 string
targetMacro ( GetTargetMacro ( module
) );
3664 string workingDirectory
= GetWorkingDirectory ( );
3665 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3667 GenerateImportLibraryTargetIfNeeded ();
3669 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3673 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3675 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3676 module
.GetEntryPoint(true).c_str (),
3677 module
.baseaddress
.c_str () );
3678 GenerateLinkerCommand ( dependencies
,
3684 GeneratePhonyTarget();
3689 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
3690 const Module
& module_
)
3692 : MingwModuleHandler ( module_
)
3697 MingwRpcServerModuleHandler::Process ()
3703 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
3704 const Module
& module_
)
3706 : MingwModuleHandler ( module_
)
3711 MingwRpcClientModuleHandler::Process ()
3717 MingwRpcProxyModuleHandler::MingwRpcProxyModuleHandler (
3718 const Module
& module_
)
3720 : MingwModuleHandler ( module_
)
3725 MingwRpcProxyModuleHandler::Process ()
3731 MingwAliasModuleHandler::MingwAliasModuleHandler (
3732 const Module
& module_
)
3734 : MingwModuleHandler ( module_
)
3739 MingwAliasModuleHandler::Process ()
3743 MingwMessageHeaderModuleHandler::MingwMessageHeaderModuleHandler (
3744 const Module
& module_
)
3746 : MingwModuleHandler ( module_
)
3751 MingwMessageHeaderModuleHandler::Process ()
3756 MingwIdlHeaderModuleHandler::MingwIdlHeaderModuleHandler (
3757 const Module
& module_
)
3759 : MingwModuleHandler ( module_
)
3764 MingwIdlHeaderModuleHandler::Process ()
3769 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3770 const Module
& module_
)
3772 : MingwModuleHandler ( module_
)
3777 MingwCabinetModuleHandler::Process ()
3779 string
targetMacro ( GetTargetMacro (module
) );
3783 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3784 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3785 targetMacro
.c_str (),
3786 backend
->GetFullPath ( *target_file
).c_str () );
3788 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3789 fprintf ( fMakefile
,
3790 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3791 targetMacro
.c_str (),
3792 module
.name
.c_str());
3795 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3796 const Module
& module_
)
3798 : MingwModuleHandler ( module_
)
3803 MingwElfExecutableModuleHandler::Process ()
3805 string
targetName ( module
.output
->name
);
3806 string
targetMacro ( GetTargetMacro (module
) );
3807 string workingDirectory
= GetWorkingDirectory ();
3808 string objectsMacro
= GetObjectsMacro ( module
);
3809 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3810 string libsMacro
= GetLibsMacro ();
3814 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3815 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3816 targetMacro
.c_str (),
3817 objectsMacro
.c_str (),
3818 linkDepsMacro
.c_str (),
3819 backend
->GetFullPath ( *target_file
).c_str () );
3821 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3823 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3824 module
.buildtype
.c_str(),
3825 objectsMacro
.c_str(),
3827 targetMacro
.c_str () );