2 * Copyright (C) 2005 Casper S. Hornstrup
3 * 2007-2008 Hervé Poussineau
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "../../pch.h"
23 #include "../../rbuild.h"
25 #include "modulehandler.h"
32 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
33 #define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
36 MingwModuleHandler::backend
= NULL
;
38 MingwModuleHandler::fMakefile
= NULL
;
42 const string
& filename
,
43 const string
& prefix
)
45 if ( !prefix
.length() )
48 const char* pfilename
= filename
.c_str();
49 const char* p1
= strrchr ( pfilename
, '/' );
50 const char* p2
= strrchr ( pfilename
, '\\' );
55 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
58 out
+= prefix
+ pfilename
;
63 GetTargetMacro ( const Module
& module
, bool with_dollar
)
65 string
s ( module
.name
);
69 return ssprintf ( "$(%s)", s
.c_str() );
73 MingwModuleHandler::MingwModuleHandler (
74 const Module
& module_
)
81 MingwModuleHandler::~MingwModuleHandler()
86 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
92 MingwModuleHandler::SetMakefile ( FILE* f
)
98 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
103 /*static*/ const FileLocation
*
104 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
106 switch ( file
->directory
)
108 case SourceDirectory
:
110 case IntermediateDirectory
:
111 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
113 case OutputDirectory
:
114 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
116 case InstallDirectory
:
117 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
120 throw InvalidOperationException ( __FILE__
,
122 "Invalid directory %d.",
129 /* caller needs to delete the returned object */
131 MingwModuleHandler::GetTargetFilename (
132 const Module
& module
,
133 string_list
* pclean_files
)
135 FileLocation
*target
= new FileLocation ( *module
.output
);
138 string_list
& clean_files
= *pclean_files
;
139 CLEAN_FILE ( *target
);
144 /* caller needs to delete the returned object */
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 FileLocation
*target
= new FileLocation ( *module
.dependency
);
153 string_list
& clean_files
= *pclean_files
;
154 CLEAN_FILE ( *target
);
159 /* caller needs to delete the returned object */
161 MingwModuleHandler::InstanciateHandler (
162 const Module
& module
,
163 MingwBackend
* backend
)
165 MingwModuleHandler
* handler
;
166 switch ( module
.type
)
169 case HostStaticLibrary
:
176 case EmbeddedTypeLib
:
178 handler
= new MingwModuleHandler( module
);
181 handler
= new MingwBuildToolModuleHandler ( module
);
184 handler
= new MingwKernelModuleHandler ( module
);
187 handler
= new MingwNativeCUIModuleHandler ( module
);
190 handler
= new MingwWin32CUIModuleHandler ( module
);
194 handler
= new MingwWin32GUIModuleHandler ( module
);
198 case KernelModeDriver
:
199 handler
= new MingwKernelModeDLLModuleHandler ( module
);
202 handler
= new MingwNativeDLLModuleHandler ( module
);
205 handler
= new MingwWin32DLLModuleHandler ( module
);
208 handler
= new MingwWin32OCXModuleHandler ( module
);
211 handler
= new MingwBootLoaderModuleHandler ( module
);
214 handler
= new MingwBootProgramModuleHandler ( module
);
217 handler
= new MingwIsoModuleHandler ( module
);
220 handler
= new MingwLiveIsoModuleHandler ( module
);
223 handler
= new MingwIsoModuleHandler ( module
);
226 handler
= new MingwLiveIsoModuleHandler ( module
);
229 handler
= new MingwTestModuleHandler ( module
);
232 handler
= new MingwAliasModuleHandler ( module
);
235 handler
= new MingwCabinetModuleHandler ( module
);
238 handler
= new MingwElfExecutableModuleHandler ( module
);
241 throw UnknownModuleTypeException (
242 module
.node
.location
,
250 MingwModuleHandler::GetWorkingDirectory () const
256 MingwModuleHandler::GetBasename ( const string
& filename
) const
258 size_t index
= filename
.find_last_of ( '.' );
259 if ( index
!= string::npos
)
260 return filename
.substr ( 0, index
);
265 MingwModuleHandler::GetCompilationUnitDependencies (
266 const CompilationUnit
& compilationUnit
) const
268 if ( compilationUnit
.GetFiles ().size () <= 1 )
270 vector
<string
> sourceFiles
;
271 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
273 const File
& file
= *compilationUnit
.GetFiles ()[i
];
274 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
276 return string ( " " ) + v2s ( sourceFiles
, 10 );
279 /* caller needs to delete the returned object */
281 MingwModuleHandler::GetModuleArchiveFilename () const
283 if ( IsStaticLibrary ( module
) )
284 return GetTargetFilename ( module
, NULL
);
285 return new FileLocation ( IntermediateDirectory
,
286 module
.output
->relative_path
,
287 ReplaceExtension ( module
.name
, ".temp.a" ) );
291 MingwModuleHandler::ReferenceObjects (
292 const Module
& module
)
294 if ( module
.type
== ObjectLibrary
)
296 if ( module
.type
== RpcServer
)
298 if ( module
.type
== RpcClient
)
300 if ( module
.type
== RpcProxy
)
302 if ( module
.type
== IdlHeader
)
304 if ( module
.type
== MessageHeader
)
310 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
311 const FileLocation
& destination
)
313 fprintf ( fMakefile
, "# OUTPUT COPY COMMAND\n" );
317 "\t${cp} %s %s 1>$(NUL)\n",
318 backend
->GetFullName ( source
).c_str (),
319 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
323 MingwModuleHandler::GetImportLibraryDependency (
324 const Module
& importedModule
)
327 if ( ReferenceObjects ( importedModule
) )
329 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
332 dep
= GetTargetMacro ( importedModule
);
333 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
335 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
336 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
337 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
338 if ( GetExtension ( *objectFilename
) == ".h" )
339 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
340 else if ( GetExtension ( *objectFilename
) == ".rc" )
341 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
346 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
);
347 dep
= backend
->GetFullName ( *library_target
);
348 delete library_target
;
351 if ( IsStaticLibrary ( importedModule
) || importedModule
.type
== ObjectLibrary
)
353 const std::vector
<Library
*>& libraries
= importedModule
.non_if_data
.libraries
;
355 for ( size_t i
= 0; i
< libraries
.size (); ++ i
)
358 dep
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
366 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
367 string_list
& targets
)
369 if ( dependencyModule
.invocations
.size () > 0 )
371 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
373 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
374 invoke
.GetTargets ( targets
);
378 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
382 MingwModuleHandler::GetModuleDependencies (
383 string_list
& dependencies
)
385 size_t iend
= module
.dependencies
.size ();
390 for ( size_t i
= 0; i
< iend
; i
++ )
392 const Dependency
& dependency
= *module
.dependencies
[i
];
393 const Module
& dependencyModule
= *dependency
.dependencyModule
;
394 GetTargets ( dependencyModule
,
397 vector
<FileLocation
> v
;
398 GetDefinitionDependencies ( v
);
400 for ( size_t i
= 0; i
< v
.size (); i
++ )
402 const FileLocation
& file
= v
[i
];
403 dependencies
.push_back ( backend
->GetFullName ( file
) );
407 /* caller needs to delete the returned object */
409 MingwModuleHandler::GetObjectFilename (
410 const FileLocation
* sourceFile
,
411 const Module
& module
) const
413 DirectoryLocation destination_directory
;
415 string extension
= GetExtension ( *sourceFile
);
417 if ( module
.type
== BootSector
)
418 return new FileLocation ( *module
.output
);
419 else if (extension
== ".rc")
420 newExtension
= "_" + module
.name
+ ".coff";
421 else if (extension
== ".mc")
422 newExtension
= ".rc";
423 else if (extension
== ".spec" || extension
== ".pspec")
424 newExtension
= "_" + module
.name
+ ".stubs.o";
425 else if (extension
== ".idl")
427 if ( module
.type
== RpcServer
)
428 newExtension
= "_s.o";
429 else if ( module
.type
== RpcClient
)
430 newExtension
= "_c.o";
431 else if ( module
.type
== RpcProxy
)
432 newExtension
= "_p.o";
437 newExtension
= "_" + module
.name
+ ".o";
439 if ( module
.type
== BootSector
)
440 destination_directory
= OutputDirectory
;
442 destination_directory
= IntermediateDirectory
;
444 const FileLocation
*obj_file
= new FileLocation(
445 destination_directory
,
446 sourceFile
->relative_path
,
447 ReplaceExtension ( sourceFile
->name
, newExtension
) );
448 PassThruCacheDirectory ( obj_file
);
454 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
456 return module
.name
+ "_clean";
460 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
462 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
464 Library
& library
= *module
.non_if_data
.libraries
[i
];
465 if ( library
.importedModule
->type
== ObjectLibrary
)
466 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
471 MingwModuleHandler::GenerateCleanTarget () const
473 if ( module
.type
== Alias
)
476 fprintf ( fMakefile
, "# CLEAN TARGET\n" );
478 ".PHONY: %s_clean\n",
479 module
.name
.c_str() );
480 vector
<string
> referencedModuleNames
;
481 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
484 GetModuleCleanTarget ( module
).c_str(),
485 v2s ( referencedModuleNames
, 10 ).c_str () );
486 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
488 if ( ( i
+ 1 ) % 10 == 9 )
489 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
490 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
492 fprintf ( fMakefile
, " 2>$(NUL)\n" );
494 if( ProxyMakefile::GenerateProxyMakefile(module
) )
496 DirectoryLocation root
;
498 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
499 root
= SourceDirectory
;
501 root
= OutputDirectory
;
503 FileLocation
proxyMakefile ( root
,
504 module
.output
->relative_path
,
506 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
507 backend
->GetFullName ( proxyMakefile
).c_str () );
510 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
514 MingwModuleHandler::GenerateInstallTarget () const
516 if ( !module
.install
)
518 fprintf ( fMakefile
, "# INSTALL TARGET\n" );
519 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
522 module
.name
.c_str (),
523 backend
->GetFullName ( *module
.install
).c_str () );
527 MingwModuleHandler::GenerateDependsTarget () const
529 fprintf ( fMakefile
, "# DEPENDS TARGET\n" );
531 ".PHONY: %s_depends\n",
532 module
.name
.c_str() );
534 "%s_depends: $(RBUILD_TARGET)\n",
535 module
.name
.c_str () );
537 "\t$(ECHO_RBUILD)\n" );
539 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
540 module
.name
.c_str () );
544 MingwModuleHandler::GetObjectFilenames ()
546 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
547 if ( compilationUnits
.size () == 0 )
550 string
objectFilenames ( "" );
551 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
553 if ( objectFilenames
.size () > 0 )
554 objectFilenames
+= " ";
555 const FileLocation
& compilationName
= compilationUnits
[i
]->GetFilename ();
556 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
557 objectFilenames
+= backend
->GetFullName ( *object_file
);
560 return objectFilenames
;
564 MingwModuleHandler::GenerateGccDefineParametersFromVector (
565 const vector
<Define
*>& defines
,
566 set
<string
>& used_defs
)
570 for ( size_t i
= 0; i
< defines
.size (); i
++ )
572 Define
& define
= *defines
[i
];
573 if (used_defs
.find(define
.name
) != used_defs
.end())
575 if (parameters
.length () > 0)
577 if (define
.name
.find('(') != string::npos
)
578 parameters
+= "$(QT)";
580 parameters
+= define
.name
;
581 if (define
.value
.length () > 0)
584 parameters
+= define
.value
;
586 if (define
.name
.find('(') != string::npos
)
587 parameters
+= "$(QT)";
588 used_defs
.insert(used_defs
.begin(),define
.name
);
594 MingwModuleHandler::ConcatenatePaths (
596 const string
& path2
) const
598 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
600 if ( path1
[path1
.length ()] == cSep
)
601 return path1
+ path2
;
603 return path1
+ cSep
+ path2
;
607 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
609 string parameters
, path_prefix
;
610 for ( size_t i
= 0; i
< includes
.size (); i
++ )
612 Include
& include
= *includes
[i
];
613 if ( parameters
.length () > 0 )
615 parameters
+= "-I" + backend
->GetFullPath ( *include
.directory
);;
621 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const
624 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
626 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
627 if ( compilerFlag
.compiler
== type
)
628 parameters
+= " " + compilerFlag
.flag
;
634 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
637 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
639 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
640 if ( parameters
.length () > 0 )
642 parameters
+= linkerFlag
.flag
;
648 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
649 const vector
<Library
*>& libraries
)
651 string
dependencies ( "" );
653 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
655 if ( wrap_count
++ == 5 )
656 dependencies
+= " \\\n\t\t", wrap_count
= 0;
657 else if ( dependencies
.size () > 0 )
659 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
);
665 MingwModuleHandler::GenerateLinkerParameters () const
667 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
671 MingwModuleHandler::GenerateMacro (
672 const char* assignmentOperation
,
674 const IfableData
& data
,
675 set
<const Define
*> *used_defs
,
676 bool generatingCompilerMacro
)
679 bool generateAssignment
;
681 generateAssignment
= (use_pch
&& module
.pch
!= NULL
) || data
.includes
.size () > 0 || data
.defines
.size () > 0;
682 if ( generatingCompilerMacro
)
683 generateAssignment
|= data
.compilerFlags
.size () > 0;
684 if ( generateAssignment
)
689 assignmentOperation
);
692 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
697 backend
->GetFullPath ( *pchFilename
).c_str () );
701 if ( generatingCompilerMacro
)
703 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, CompilerTypeDontCare
);
704 if ( compilerParameters
.size () > 0 )
709 compilerParameters
.c_str () );
712 for ( i
= 0; i
< data
.includes
.size(); i
++ )
714 const Include
& include
= *data
.includes
[i
];
715 const FileLocation
* includeDirectory
= include
.directory
;
719 backend
->GetFullPath ( *includeDirectory
).c_str() );
721 for ( i
= 0; i
< data
.defines
.size(); i
++ )
723 const Define
& define
= *data
.defines
[i
];
726 set
<const Define
*>::const_iterator last_define
;
727 for (last_define
= used_defs
->begin ();
728 last_define
!= used_defs
->end ();
731 if ( (*last_define
)->name
!= define
.name
)
733 if ( !define
.overridable
)
735 throw InvalidOperationException ( (*last_define
)->node
->location
.c_str (),
737 "Invalid override of define '%s', already defined at %s",
738 define
.name
.c_str (),
739 define
.node
->location
.c_str () );
741 if ( backend
->configuration
.Verbose
)
742 printf("%s: Overriding '%s' already defined at %s\n",
743 (*last_define
)->node
->location
.c_str (), define
.name
.c_str (),
744 define
.node
->location
.c_str () );
747 if ( last_define
!= used_defs
->end () )
753 define
.name
.c_str() );
754 if (define
.value
.length () > 0)
758 define
.value
.c_str() );
760 used_defs
->insert( used_defs
->begin (), &define
);
762 if ( generateAssignment
)
764 fprintf ( fMakefile
, "\n" );
769 MingwModuleHandler::GenerateMacros (
770 const char* assignmentOperation
,
771 const IfableData
& data
,
772 const vector
<LinkerFlag
*>* linkerFlags
,
773 set
<const Define
*>& used_defs
)
775 fprintf ( fMakefile
, "# MACROS\n" );
776 GenerateMacro ( assignmentOperation
,
781 GenerateMacro ( assignmentOperation
,
787 if ( linkerFlags
!= NULL
)
789 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
790 if ( linkerParameters
.size () > 0 )
795 linkerflagsMacro
.c_str (),
797 linkerParameters
.c_str() );
801 if ( data
.libraries
.size () > 0 )
803 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
804 if ( deps
.size () > 0 )
817 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
819 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
820 delete compilationUnits
[i
];
824 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
829 MingwModuleHandler::GenerateSourceMacros (
830 const IfableData
& data
)
834 fprintf ( fMakefile
, "# SOURCE MACROS\n" );
835 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
836 vector
<const FileLocation
*> headers
;
837 if ( compilationUnits
.size () > 0 )
842 sourcesMacro
.c_str () );
843 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
845 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
846 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
850 ( i
%10 == 9 ? " \\\n\t" : " " ),
851 backend
->GetFullName ( compilationName
).c_str () );
853 fprintf ( fMakefile
, "\n" );
856 vector
<CompilationUnit
*> sourceCompilationUnits
;
857 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
858 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
860 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
864 sourcesMacro
.c_str(),
865 backend
->GetFullName ( compilationName
).c_str () );
867 CleanupCompilationUnitVector ( sourceCompilationUnits
);
871 MingwModuleHandler::GenerateObjectMacros (
872 const IfableData
& data
)
875 const char* assignmentOperation
= "=";
877 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
878 vector
<const FileLocation
*> headers
;
879 vector
<const FileLocation
*> mcheaders
;
880 vector
<const FileLocation
*> mcresources
;
881 fprintf ( fMakefile
, "# OBJECT MACROS\n" );
882 if ( compilationUnits
.size () > 0 )
884 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
886 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
887 if ( compilationUnit
.IsFirstFile () )
889 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
890 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
893 objectsMacro
.c_str(),
894 backend
->GetFullName ( *object_file
).c_str () );
896 assignmentOperation
= "+=";
903 objectsMacro
.c_str (),
904 assignmentOperation
);
905 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
907 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
908 if ( !compilationUnit
.IsFirstFile () )
910 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
911 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
912 if ( GetExtension ( *objectFilename
) == ".h" )
913 headers
.push_back ( objectFilename
);
914 else if ( GetExtension ( *objectFilename
) == ".rc" )
916 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
917 mcheaders
.push_back ( headerFilename
);
918 mcresources
.push_back ( objectFilename
);
925 ( i
%10 == 9 ? " \\\n\t" : " " ),
926 backend
->GetFullName ( *objectFilename
).c_str () );
927 delete objectFilename
;
931 fprintf ( fMakefile
, "\n" );
933 if ( headers
.size () > 0 )
938 module
.name
.c_str (),
939 assignmentOperation
);
940 for ( i
= 0; i
< headers
.size (); i
++ )
945 ( i
%10 == 9 ? " \\\n\t" : " " ),
946 backend
->GetFullName ( *headers
[i
] ).c_str () );
949 fprintf ( fMakefile
, "\n" );
952 if ( mcheaders
.size () > 0 )
957 module
.name
.c_str (),
958 assignmentOperation
);
959 for ( i
= 0; i
< mcheaders
.size (); i
++ )
964 ( i
%10 == 9 ? " \\\n\t" : " " ),
965 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
968 fprintf ( fMakefile
, "\n" );
971 if ( mcresources
.size () > 0 )
976 module
.name
.c_str (),
977 assignmentOperation
);
978 for ( i
= 0; i
< mcresources
.size (); i
++ )
983 ( i
%10 == 9 ? " \\\n\t" : " " ),
984 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
985 delete mcresources
[i
];
987 fprintf ( fMakefile
, "\n" );
990 vector
<CompilationUnit
*> sourceCompilationUnits
;
991 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
992 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
994 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
995 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
999 objectsMacro
.c_str(),
1000 backend
->GetFullName ( *object_file
).c_str () );
1003 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1006 /* caller needs to delete the returned object */
1008 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1010 if ( !module
.pch
|| !use_pch
)
1012 return new FileLocation ( IntermediateDirectory
,
1013 module
.pch
->file
->relative_path
+ "/.gch_" + module
.name
,
1014 module
.pch
->file
->name
+ ".gch" );
1017 Rule
arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) $(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
1018 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
1019 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1020 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1021 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1023 Rule
arHostRule2 ( "\t$(ECHO_AR)\n"
1024 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1026 Rule
gasRule ( "$(source): ${$(module_name)_precondition}\n"
1027 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1029 "\t${gcc} -x assembler-with-cpp -o $@ -D__ASM__ $($(module_name)_CFLAGS) -c $<\n",
1030 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1031 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1032 Rule
bootRule ( "$(source): ${$(module_name)_precondition}\n"
1033 "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
1035 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1036 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1037 Rule
nasmRule ( "$(source): ${$(module_name)_precondition}\n"
1038 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1040 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
1041 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
1042 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1043 Rule
windresRule ( "$(source): ${$(module_name)_precondition}\n"
1044 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
1046 "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
1047 "\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"
1048 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
1049 "\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
1050 "\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
1051 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
1052 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1053 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"
1055 "\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",
1056 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
1057 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1058 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1059 Rule
winebuildPDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1060 "\t$(ECHO_WINEBLD)\n"
1061 "\t${gcc} -xc -E ${$(module_name)_RCFLAGS} $(source) > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).def.spec\n"
1062 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def --def -E $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).def.spec\n\n",
1063 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).def.spec",
1064 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1065 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1066 Rule
winebuildPRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c: $(source_path)$(SEP)$(source_name_noext).pspec $(WINEBUILD_TARGET)\n"
1067 "\t$(ECHO_WINEBLD)\n"
1068 "\t${gcc} -xc -E ${$(module_name)_RCFLAGS} $(source) > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.spec\n"
1069 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).stubs.c --pedll $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).stubs.spec\n"
1070 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1072 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1073 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.spec",
1074 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1075 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1076 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1077 Rule
winebuildDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1078 "\t$(ECHO_WINEBLD)\n"
1079 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).auto.def --def -E $(source)\n\n",
1080 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
1081 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
1082 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1083 Rule
winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
1084 "\t$(ECHO_WINEBLD)\n"
1085 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).stubs.c --pedll $(source_path)$(SEP)$(source_name_noext).spec\n"
1086 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1088 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1089 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
1090 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
1091 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1092 Rule
widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
1093 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1095 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
1096 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
1097 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1098 Rule
widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
1099 "$(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"
1101 "\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"
1102 "$(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"
1104 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1105 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
1106 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
1107 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
1108 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1109 Rule
widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
1110 "$(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"
1112 "\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"
1113 "$(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"
1115 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1116 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
1117 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
1118 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
1119 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1120 Rule
widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
1121 "$(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"
1123 "\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"
1124 "$(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"
1126 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1127 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
1128 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
1129 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
1130 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1131 Rule
widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
1132 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1134 "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
1135 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL
);
1136 Rule
gccRule ( "$(source): ${$(module_name)_precondition}\n"
1137 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1139 "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1140 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1141 Rule
gccHostRule ( "$(source): ${$(module_name)_precondition}\n"
1142 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1144 "\t${host_gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1145 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1146 Rule
gppRule ( "$(source): ${$(module_name)_precondition}\n"
1147 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1149 "\t${gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1150 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1151 Rule
gppHostRule ( "$(source): ${$(module_name)_precondition}\n"
1152 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
1154 "\t${host_gpp} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
1155 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL
);
1156 Rule
emptyRule ( "", NULL
);
1159 MingwModuleHandler::GenerateGccCommand (
1160 const FileLocation
* sourceFile
,
1162 const string
& extraDependencies
)
1164 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1165 string dependencies
= extraDependencies
;
1168 string extension
= GetExtension ( *sourceFile
);
1169 if ( extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1170 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCPP
);
1172 flags
= GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, CompilerTypeCC
);
1176 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1180 /* WIDL generated headers may be used */
1181 vector
<FileLocation
> rpcDependencies
;
1182 GetRpcHeaderDependencies ( rpcDependencies
);
1183 if ( rpcDependencies
.size () > 0 )
1184 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1186 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
, flags
);
1190 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1192 const Property
* property
= module
.project
.LookupProperty(name
);
1195 return property
->value
;
1197 return string ( "" );
1200 /* caller needs to delete the returned object */
1202 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1204 string newname
= GetBasename ( base
->name
) + "_s.h";
1205 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1208 /* caller needs to delete the returned object */
1210 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1212 string newname
= GetBasename ( base
->name
) + "_c.h";
1213 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1216 /* caller needs to delete the returned object */
1218 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1220 string newname
= GetBasename ( base
->name
) + "_p.h";
1221 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1224 /* caller needs to delete the returned object */
1226 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1228 string newname
= GetBasename ( base
->name
) + ".h";
1229 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1232 /* caller needs to delete the returned object */
1234 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1236 string newname
= GetBasename ( base
->name
) + ".h";
1237 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1241 MingwModuleHandler::GenerateCommands (
1242 const CompilationUnit
& compilationUnit
,
1243 const string
& extraDependencies
)
1245 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1246 string extension
= GetExtension ( sourceFile
);
1247 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1256 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1257 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1258 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1259 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1260 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1261 { HostDontCare
, TypeDontCare
, ".pspec", &winebuildPRule
},
1262 { HostDontCare
, TypeDontCare
, ".spec", &winebuildRule
},
1263 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1264 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1265 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1266 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1267 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1268 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1269 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1270 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1271 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1272 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1273 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1274 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1275 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1276 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1279 Rule
*customRule
= NULL
;
1281 fprintf ( fMakefile
, "# COMMANDS\n" );
1283 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1285 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1287 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1289 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1291 customRule
= rules
[i
].rule
;
1295 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1297 GenerateGccCommand ( &sourceFile
,
1299 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1301 else if ( customRule
)
1302 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1305 throw InvalidOperationException ( __FILE__
,
1307 "Unsupported filename extension '%s' in file '%s'",
1309 backend
->GetFullName ( sourceFile
).c_str () );
1314 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1316 fprintf ( fMakefile
, "# BUILD MAP CODE\n" );
1318 fprintf ( fMakefile
,
1319 "ifeq ($(ROS_BUILDMAP),full)\n" );
1321 FileLocation
mapFilename ( OutputDirectory
,
1322 module
.output
->relative_path
,
1323 GetBasename ( module
.output
->name
) + ".map" );
1324 CLEAN_FILE ( mapFilename
);
1326 fprintf ( fMakefile
,
1327 "\t$(ECHO_OBJDUMP)\n" );
1328 fprintf ( fMakefile
,
1329 "\t$(Q)${objdump} -d -S %s > %s\n",
1330 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1331 backend
->GetFullName ( mapFilename
).c_str () );
1333 fprintf ( fMakefile
,
1335 fprintf ( fMakefile
,
1336 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1338 fprintf ( fMakefile
,
1340 fprintf ( fMakefile
,
1341 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1342 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1343 backend
->GetFullName ( mapFilename
).c_str () );
1345 fprintf ( fMakefile
,
1348 fprintf ( fMakefile
,
1353 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1355 fprintf ( fMakefile
, "# BUILD NO STRIP CODE\n" );
1357 fprintf ( fMakefile
,
1358 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1360 FileLocation
nostripFilename ( OutputDirectory
,
1361 module
.output
->relative_path
,
1362 GetBasename ( module
.output
->name
) + ".nostrip" + GetExtension ( *module
.output
) );
1363 CLEAN_FILE ( nostripFilename
);
1365 OutputCopyCommand ( *module
.output
, nostripFilename
);
1367 fprintf ( fMakefile
,
1372 MergeStringVector ( const Backend
* backend
,
1373 const vector
<FileLocation
>& input
,
1374 vector
<string
>& output
)
1378 int wrap_count
= -1;
1379 for ( size_t i
= 0; i
< input
.size (); i
++ )
1381 if ( wrap_count
++ == wrap_at
)
1383 output
.push_back ( s
);
1387 else if ( s
.size () > 0)
1389 s
+= backend
->GetFullName ( input
[i
] );
1391 if ( s
.length () > 0 )
1392 output
.push_back ( s
);
1396 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1397 vector
<FileLocation
>& objectFiles
) const
1399 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1401 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1402 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1403 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1404 objectFiles
.push_back ( *object_file
);
1410 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1412 if ( backend
->configuration
.CleanAsYouGo
)
1414 vector
<FileLocation
> objectFiles
;
1415 GetObjectsVector ( module
.non_if_data
,
1417 vector
<string
> lines
;
1418 MergeStringVector ( backend
,
1421 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1423 fprintf ( fMakefile
,
1424 "\t-@${rm} %s 2>$(NUL)\n",
1425 lines
[i
].c_str () );
1431 MingwModuleHandler::GenerateRunRsymCode () const
1433 fprintf ( fMakefile
, "# RUN RSYM CODE\n" );
1434 fprintf ( fMakefile
,
1435 "ifneq ($(ROS_GENERATE_RSYM),no)\n" );
1436 fprintf ( fMakefile
,
1437 "\t$(ECHO_RSYM)\n" );
1438 fprintf ( fMakefile
,
1439 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1440 fprintf ( fMakefile
,
1445 MingwModuleHandler::GenerateRunStripCode () const
1447 fprintf ( fMakefile
, "# RUN STRIP CODE\n" );
1448 fprintf ( fMakefile
,
1449 "ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
1450 fprintf ( fMakefile
,
1451 "\t$(ECHO_STRIP)\n" );
1452 fprintf ( fMakefile
,
1453 "\t${strip} -s -x -X $@\n\n" );
1454 fprintf ( fMakefile
,
1459 MingwModuleHandler::GenerateLinkerCommand (
1460 const string
& dependencies
,
1461 const string
& linkerParameters
,
1462 const string
& pefixupParameters
)
1464 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1465 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1466 string linker
= "${ld}";
1467 string objectsMacro
= GetObjectsMacro ( module
);
1468 string libsMacro
= GetLibsMacro ();
1470 fprintf ( fMakefile
, "# LINKER COMMAND\n" );
1472 string
target_macro ( GetTargetMacro ( module
) );
1473 string
target_folder ( backend
->GetFullPath ( *target_file
) );
1475 string linkerScriptArgument
;
1476 if ( module
.linkerScript
!= NULL
)
1477 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1479 linkerScriptArgument
= "";
1481 /* check if we need to add default C++ libraries, ie if we have
1482 * a C++ user-mode module without the -nostdlib linker flag
1484 bool link_defaultlibs
= module
.cplusplus
&&
1485 linkerParameters
.find ("-nostdlib") == string::npos
&&
1486 !(module
.type
== KernelModeDLL
|| module
.type
== KernelModeDriver
);
1488 string
targetName ( module
.output
->name
);
1490 if ( !module
.HasImportLibrary() )
1492 fprintf ( fMakefile
,
1493 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1494 target_macro
.c_str (),
1495 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1496 dependencies
.c_str (),
1497 target_folder
.c_str () );
1498 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1500 fprintf ( fMakefile
,
1501 "\t%s %s%s %s %s %s %s -o %s\n",
1503 linkerParameters
.c_str (),
1504 linkerScriptArgument
.c_str (),
1505 objectsMacro
.c_str (),
1506 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1508 GetLinkerMacro ().c_str (),
1509 target_macro
.c_str () );
1513 FileLocation
temp_exp ( IntermediateDirectory
,
1514 module
.output
->relative_path
,
1515 module
.name
+ ".exp" );
1516 CLEAN_FILE ( temp_exp
);
1518 fprintf ( fMakefile
,
1520 backend
->GetFullName ( temp_exp
).c_str (),
1521 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1522 backend
->GetFullPath ( temp_exp
).c_str () );
1523 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1525 fprintf ( fMakefile
,
1526 "\t${dlltool} --dllname %s --def %s --output-exp $@%s%s\n",
1527 targetName
.c_str (),
1528 definitionFilename
? backend
->GetFullName ( *definitionFilename
).c_str () : "",
1529 module
.mangledSymbols
? "" : " --kill-at",
1530 module
.underscoreSymbols
? " --add-underscore" : "" );
1532 fprintf ( fMakefile
,
1533 "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
1534 target_macro
.c_str (),
1535 backend
->GetFullName ( temp_exp
).c_str (),
1536 dependencies
.c_str (),
1537 target_folder
.c_str () );
1538 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1540 fprintf ( fMakefile
,
1541 "\t%s %s%s %s %s %s %s %s -o %s\n",
1544 linkerParameters
.c_str (),
1545 linkerScriptArgument
.c_str (),
1546 backend
->GetFullName ( temp_exp
).c_str (),
1547 objectsMacro
.c_str (),
1548 link_defaultlibs
? "$(PROJECT_LPPFLAGS) " : "",
1550 GetLinkerMacro ().c_str (),
1551 target_macro
.c_str () );
1553 fprintf ( fMakefile
,
1554 "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
1555 target_macro
.c_str (),
1556 pefixupParameters
.c_str() );
1559 GenerateBuildMapCode ();
1560 GenerateBuildNonSymbolStrippedCode ();
1561 GenerateRunRsymCode ();
1562 GenerateRunStripCode ();
1563 GenerateCleanObjectsAsYouGoCode ();
1565 if ( definitionFilename
)
1566 delete definitionFilename
;
1571 MingwModuleHandler::GeneratePhonyTarget() const
1573 string
targetMacro ( GetTargetMacro ( module
) );
1574 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1576 fprintf ( fMakefile
, "# PHONY TARGET\n" );
1577 fprintf ( fMakefile
,
1579 targetMacro
.c_str ());
1580 fprintf ( fMakefile
, "%s: | %s\n",
1581 targetMacro
.c_str (),
1582 backend
->GetFullPath ( *target_file
).c_str () );
1588 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1591 string moduleDependencies
;
1593 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1595 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1596 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1598 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1599 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1600 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1601 if ( GetExtension ( *objectFilename
) == ".h" )
1602 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1603 else if ( GetExtension ( *objectFilename
) == ".rc" )
1604 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1605 delete objectFilename
;
1608 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1610 GenerateCommands ( *compilationUnits
[i
],
1611 moduleDependencies
);
1612 fprintf ( fMakefile
,
1616 vector
<CompilationUnit
*> sourceCompilationUnits
;
1617 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1618 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1620 GenerateCommands ( *sourceCompilationUnits
[i
],
1621 moduleDependencies
);
1623 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1627 MingwModuleHandler::GenerateObjectFileTargets ()
1629 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1631 fprintf ( fMakefile
, "# OBJECT FILE TARGETS\n" );
1635 string cc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gcc}" : "${gcc}" );
1636 string cppc
= ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
? "${host_gpp}" : "${gpp}" );
1638 const FileLocation
& baseHeaderFile
= *module
.pch
->file
;
1639 CLEAN_FILE ( *pchFilename
);
1640 string dependencies
= backend
->GetFullName ( baseHeaderFile
);
1641 /* WIDL generated headers may be used */
1642 vector
<FileLocation
> rpcDependencies
;
1643 GetRpcHeaderDependencies ( rpcDependencies
);
1644 if ( rpcDependencies
.size () > 0 )
1645 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1646 fprintf ( fMakefile
,
1648 backend
->GetFullName ( *pchFilename
).c_str(),
1649 dependencies
.c_str(),
1650 backend
->GetFullPath ( *pchFilename
).c_str() );
1651 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1652 fprintf ( fMakefile
,
1653 "\t%s -o %s %s %s -g %s\n\n",
1654 module
.cplusplus
? cppc
.c_str() : cc
.c_str(),
1655 backend
->GetFullName ( *pchFilename
).c_str(),
1656 cflagsMacro
.c_str(),
1657 GenerateCompilerParametersFromVector ( module
.non_if_data
.compilerFlags
, module
.cplusplus
? CompilerTypeCPP
: CompilerTypeCC
).c_str(),
1658 backend
->GetFullName ( baseHeaderFile
).c_str() );
1662 GenerateObjectFileTargets ( module
.non_if_data
);
1663 fprintf ( fMakefile
, "\n" );
1666 /* caller needs to delete the returned object */
1668 MingwModuleHandler::GenerateArchiveTarget ()
1670 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1671 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1673 fprintf ( fMakefile
, "# ARCHIVE TARGET\n" );
1675 if ( IsStaticLibrary ( module
) && definitionFilename
)
1677 arRule1
.Execute ( fMakefile
,
1682 backend
->GetFullName ( *definitionFilename
).c_str () );
1684 fprintf ( fMakefile
,
1685 "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
1686 module
.importLibrary
->dllname
.c_str (),
1687 backend
->GetFullName ( *definitionFilename
).c_str (),
1688 module
.mangledSymbols
? "" : " --kill-at",
1689 module
.underscoreSymbols
? " --add-underscore" : "" );
1692 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1694 if ( definitionFilename
)
1695 delete definitionFilename
;
1697 if(module
.type
== HostStaticLibrary
)
1698 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1700 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1702 GenerateCleanObjectsAsYouGoCode ();
1704 fprintf ( fMakefile
, "\n" );
1706 return archiveFilename
;
1710 MingwModuleHandler::GetCFlagsMacro () const
1712 return ssprintf ( "$(%s_CFLAGS)",
1713 module
.name
.c_str () );
1717 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1719 return ssprintf ( "$(%s_OBJS)",
1720 module
.name
.c_str () );
1724 MingwModuleHandler::GetLinkingDependenciesMacro () const
1726 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1730 MingwModuleHandler::GetLibsMacro () const
1732 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1736 MingwModuleHandler::GetLinkerMacro () const
1738 return ssprintf ( "$(%s_LFLAGS)",
1739 module
.name
.c_str () );
1743 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1745 if ( ReferenceObjects ( module
) )
1746 return GetObjectsMacro ( module
);
1749 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1750 string target
= backend
->GetFullName ( *target_file
).c_str ();
1757 MingwModuleHandler::GenerateSourceMacro ()
1759 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1761 GenerateSourceMacros ( module
.non_if_data
);
1763 // future references to the macro will be to get its values
1764 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1768 MingwModuleHandler::GenerateObjectMacro ()
1770 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1772 GenerateObjectMacros ( module
.non_if_data
);
1774 // future references to the macro will be to get its values
1775 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1779 MingwModuleHandler::GenerateTargetMacro ()
1781 fprintf ( fMakefile
, "# TARGET MACRO\n" );
1782 fprintf ( fMakefile
,
1784 GetTargetMacro ( module
, false ).c_str (),
1785 GetModuleTargets ( module
).c_str () );
1789 MingwModuleHandler::GetRpcHeaderDependencies (
1790 vector
<FileLocation
>& dependencies
) const
1792 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1794 Library
& library
= *module
.non_if_data
.libraries
[i
];
1795 if ( library
.importedModule
->type
== RpcServer
||
1796 library
.importedModule
->type
== RpcClient
||
1797 library
.importedModule
->type
== RpcProxy
||
1798 library
.importedModule
->type
== IdlHeader
)
1800 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1802 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1803 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1804 string extension
= GetExtension ( sourceFile
);
1805 if ( extension
== ".idl" || extension
== ".IDL" )
1807 string basename
= GetBasename ( sourceFile
.name
);
1808 if ( library
.importedModule
->type
== RpcServer
)
1810 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1811 dependencies
.push_back ( *header
);
1814 if ( library
.importedModule
->type
== RpcClient
)
1816 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1817 dependencies
.push_back ( *header
);
1820 if ( library
.importedModule
->type
== RpcProxy
)
1822 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1823 dependencies
.push_back ( *header
);
1826 if ( library
.importedModule
->type
== IdlHeader
)
1828 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1829 dependencies
.push_back ( *header
);
1839 MingwModuleHandler::GenerateOtherMacros ()
1841 set
<const Define
*> used_defs
;
1843 fprintf ( fMakefile
, "# OTHER MACROS\n" );
1845 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1846 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1847 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1848 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1849 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1850 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1851 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1856 &module
.linkerFlags
,
1859 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1861 GenerateMacros("+=", module
.project
.host_non_if_data
, NULL
, used_defs
);
1867 module
.project
.non_if_data
,
1872 if ( IsSpecDefinitionFile() )
1874 vector
<FileLocation
> s
;
1875 GetSpecImplibDependencies ( s
, module
.importLibrary
->source
);
1880 linkDepsMacro
.c_str() );
1881 for ( size_t i
= 0; i
< s
.size(); i
++ )
1882 fprintf ( fMakefile
,
1884 backend
->GetFullName ( s
[i
] ).c_str () );
1885 fprintf ( fMakefile
, "\n" );
1888 string globalCflags
= "";
1889 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1891 globalCflags
+= " $(PROJECT_CFLAGS)";
1892 if ( module
.dynamicCRT
)
1893 globalCflags
+= " -D_DLL -D__USE_CRTIMP";
1896 globalCflags
+= " -Wall -Wpointer-arith";
1897 globalCflags
+= " -g";
1898 if ( backend
->usePipe
)
1899 globalCflags
+= " -pipe";
1900 if ( !module
.allowWarnings
)
1901 globalCflags
+= " -Werror";
1902 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1904 if ( module
.cplusplus
)
1905 globalCflags
+= " $(HOST_CPPFLAGS)";
1907 globalCflags
+= " -Wno-strict-aliasing $(HOST_CFLAGS)";
1911 if ( module
.cplusplus
)
1913 // HACK: use host headers when building C++
1914 globalCflags
+= " $(HOST_CPPFLAGS)";
1917 globalCflags
+= " -nostdinc";
1920 // Always force disabling of sibling calls optimisation for GCC
1921 // (TODO: Move to version-specific once this bug is fixed in GCC)
1922 globalCflags
+= " -fno-optimize-sibling-calls";
1927 cflagsMacro
.c_str (),
1928 globalCflags
.c_str () );
1930 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
)
1934 "%s += $(PROJECT_RCFLAGS)\n",
1935 windresflagsMacro
.c_str () );
1939 "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
1940 widlflagsMacro
.c_str (),
1941 module
.output
->relative_path
.c_str () );
1945 "%s_LFLAGS := $(PROJECT_LFLAGS) -g $(%s_LFLAGS)\n",
1946 module
.name
.c_str (),
1947 module
.name
.c_str () );
1953 "%s_LFLAGS += $(HOST_LFLAGS)\n",
1954 module
.name
.c_str () );
1960 linkDepsMacro
.c_str (),
1961 libsMacro
.c_str () );
1963 const char *cflags
= ModuleHandlerInformations
[module
.type
].cflags
;
1964 if ( strlen( cflags
) > 0 )
1966 fprintf ( fMakefile
,
1968 cflagsMacro
.c_str (),
1972 const char* nasmflags
= ModuleHandlerInformations
[module
.type
].nasmflags
;
1973 if ( strlen( nasmflags
) > 0 )
1975 fprintf ( fMakefile
,
1977 nasmflagsMacro
.c_str (),
1981 const char *linkerflags
= ModuleHandlerInformations
[module
.type
].linkerflags
;
1982 if ( strlen( linkerflags
) > 0 )
1984 fprintf ( fMakefile
,
1986 linkerflagsMacro
.c_str (),
1990 if ( IsStaticLibrary ( module
) && module
.isStartupLib
)
1992 fprintf ( fMakefile
,
1993 "%s += -Wno-main\n\n",
1994 cflagsMacro
.c_str () );
1997 fprintf ( fMakefile
, "\n\n" );
1999 // future references to the macros will be to get their values
2000 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
2001 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
2002 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
2006 MingwModuleHandler::GenerateRules ()
2010 fprintf ( fMakefile
, "# RULES\n" );
2011 string targetMacro
= GetTargetMacro ( module
);
2012 //CLEAN_FILE ( targetMacro );
2013 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
2015 // generate phony target for module name
2016 fprintf ( fMakefile
, ".PHONY: %s\n",
2017 module
.name
.c_str () );
2018 string dependencies
= GetTargetMacro ( module
);
2019 if ( module
.type
== Test
)
2020 dependencies
+= " $(REGTESTS_RUN_TARGET)";
2021 fprintf ( fMakefile
, "%s: %s\n\n",
2022 module
.name
.c_str (),
2023 dependencies
.c_str () );
2024 if ( module
.type
== Test
)
2026 fprintf ( fMakefile
,
2028 targetMacro
.c_str ());
2031 if ( !ReferenceObjects ( module
) )
2033 const FileLocation
* ar_target
= GenerateArchiveTarget ();
2038 spec
= IsSpecDefinitionFile();
2045 defRule
= &winebuildPDefRule
;
2047 defRule
= &winebuildDefRule
;
2049 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
2052 GenerateObjectFileTargets ();
2056 MingwModuleHandler::GetInvocationDependencies (
2057 const Module
& module
,
2058 string_list
& dependencies
)
2060 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
2062 Invoke
& invoke
= *module
.invocations
[i
];
2063 if ( invoke
.invokeModule
== &module
)
2064 /* Protect against circular dependencies */
2066 invoke
.GetTargets ( dependencies
);
2071 MingwModuleHandler::GenerateInvocations () const
2073 if ( module
.invocations
.size () == 0 )
2076 fprintf ( fMakefile
, "# INVOCATIONS\n" );
2078 size_t iend
= module
.invocations
.size ();
2079 for ( size_t i
= 0; i
< iend
; i
++ )
2081 const Invoke
& invoke
= *module
.invocations
[i
];
2083 if ( invoke
.invokeModule
->type
!= BuildTool
)
2085 throw XMLInvalidBuildFileException (
2086 module
.node
.location
,
2087 "Only modules of type buildtool can be invoked." );
2090 string invokeTarget
= module
.GetInvocationTarget ( i
);
2091 string_list invoke_targets
;
2092 assert ( invoke_targets
.size() );
2093 invoke
.GetTargets ( invoke_targets
);
2094 fprintf ( fMakefile
,
2096 invokeTarget
.c_str () );
2097 fprintf ( fMakefile
,
2099 invokeTarget
.c_str () );
2100 size_t j
, jend
= invoke_targets
.size();
2101 for ( j
= 0; j
< jend
; j
++ )
2103 fprintf ( fMakefile
,
2105 invoke_targets
[i
].c_str () );
2107 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
2108 for ( j
= 1; j
< jend
; j
++ )
2109 fprintf ( fMakefile
,
2111 invoke_targets
[i
].c_str () );
2112 fprintf ( fMakefile
,
2114 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
2115 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
2116 fprintf ( fMakefile
,
2118 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
2119 invoke
.GetParameters ().c_str () );
2124 MingwModuleHandler::GetPreconditionDependenciesName () const
2126 return module
.name
+ "_precondition";
2130 MingwModuleHandler::GetDefaultDependencies (
2131 string_list
& dependencies
) const
2133 /* Avoid circular dependency */
2134 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
2137 if (module
.name
!= "psdk" &&
2138 module
.name
!= "dxsdk")
2140 dependencies
.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
2141 dependencies
.push_back ( "$(DXSDK_TARGET) $(dxsdk_HEADERS)" );
2144 if (module
.name
!= "errcodes" &&
2145 module
.name
!= "bugcodes" &&
2146 module
.name
!= "ntstatus")
2148 dependencies
.push_back ( "$(ERRCODES_TARGET) $(ERRCODES_MCHEADERS)" );
2149 dependencies
.push_back ( "$(BUGCODES_TARGET) $(BUGCODES_MCHEADERS)" );
2150 dependencies
.push_back ( "$(NTSTATUS_TARGET) $(NTSTATUS_MCHEADERS)" );
2153 ///* Check if any dependent library relies on the generated headers */
2154 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
2156 // const Module& m = *module.project.modules[i];
2157 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
2159 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
2160 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
2161 // string extension = GetExtension ( sourceFile );
2162 // if (extension == ".mc" || extension == ".MC" )
2164 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
2165 // dependencies.push_back ( dependency );
2172 MingwModuleHandler::GeneratePreconditionDependencies ()
2174 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
2175 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
2176 string_list dependencies
;
2177 GetDefaultDependencies ( dependencies
);
2178 GetModuleDependencies ( dependencies
);
2180 GetInvocationDependencies ( module
, dependencies
);
2182 if ( dependencies
.size() )
2184 fprintf ( fMakefile
,
2186 preconditionDependenciesName
.c_str () );
2187 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
2188 fprintf ( fMakefile
,
2190 dependencies
[i
].c_str () );
2191 fprintf ( fMakefile
, "\n\n" );
2194 fprintf ( fMakefile
, "\n" );
2198 MingwModuleHandler::IsSpecDefinitionFile () const
2200 if(!module
.importLibrary
)
2203 if(module
.importLibrary
->source
->name
.rfind(".spec") != string::npos
)
2206 if(module
.importLibrary
->source
->name
.rfind(".pspec") != string::npos
)
2212 /* caller needs to delete the returned object */
2214 MingwModuleHandler::GetDefinitionFilename () const
2216 if ( module
.importLibrary
== NULL
)
2219 if ( IsSpecDefinitionFile () )
2221 return new FileLocation ( IntermediateDirectory
,
2222 module
.importLibrary
->source
->relative_path
,
2223 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2227 return new FileLocation ( SourceDirectory
,
2228 module
.importLibrary
->source
->relative_path
,
2229 module
.importLibrary
->source
->name
);
2234 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
2236 if ( module
.importLibrary
!= NULL
)
2238 const FileLocation
*library_target
= GetImportLibraryFilename ( module
, &clean_files
);
2239 const FileLocation
*defFilename
= GetDefinitionFilename ();
2240 string empty
= "tools" + sSep
+ "rbuild" + sSep
+ "empty.def";
2242 vector
<FileLocation
> deps
;
2243 GetDefinitionDependencies ( deps
);
2245 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE\n" );
2247 fprintf ( fMakefile
, "%s:",
2248 backend
->GetFullName ( *library_target
).c_str () );
2252 fprintf ( fMakefile
, " %s",
2253 backend
->GetFullName ( *defFilename
).c_str () );
2256 size_t i
, iend
= deps
.size();
2257 for ( i
= 0; i
< iend
; i
++ )
2258 fprintf ( fMakefile
, " %s",
2259 backend
->GetFullName ( deps
[i
] ).c_str () );
2261 fprintf ( fMakefile
, " | %s\n",
2262 backend
->GetFullPath ( *library_target
).c_str () );
2264 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
2266 fprintf ( fMakefile
,
2267 "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
2268 module
.output
->name
.c_str (),
2269 defFilename
? backend
->GetFullName ( *defFilename
).c_str ()
2271 backend
->GetFullName ( *library_target
).c_str (),
2272 module
.mangledSymbols
? "" : " --kill-at",
2273 module
.underscoreSymbols
? " --add-underscore" : "" );
2277 delete library_target
;
2282 MingwModuleHandler::GetSpecObjectDependencies (
2283 vector
<FileLocation
>& dependencies
,
2284 const FileLocation
*file
) const
2286 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2287 file
->relative_path
,
2288 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2292 MingwModuleHandler::GetSpecImplibDependencies (
2293 vector
<FileLocation
>& dependencies
,
2294 const FileLocation
*file
) const
2296 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2297 file
->relative_path
,
2298 GetBasename ( file
->name
) + "_" + module
.name
+ ".auto.def" ) );
2302 MingwModuleHandler::GetMcObjectDependencies (
2303 vector
<FileLocation
>& dependencies
,
2304 const FileLocation
*file
) const
2306 string basename
= GetBasename ( file
->name
);
2308 FileLocation
defDependency ( IntermediateDirectory
,
2311 dependencies
.push_back ( defDependency
);
2313 FileLocation
stubsDependency ( IntermediateDirectory
,
2314 file
->relative_path
,
2316 dependencies
.push_back ( stubsDependency
);
2320 MingwModuleHandler::GetWidlObjectDependencies (
2321 vector
<FileLocation
>& dependencies
,
2322 const FileLocation
*file
) const
2324 string basename
= GetBasename ( file
->name
);
2325 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2327 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2328 file
->relative_path
,
2329 basename
+ "_s.c" );
2330 dependencies
.push_back ( serverSourceDependency
);
2331 dependencies
.push_back ( *generatedHeaderFilename
);
2333 delete generatedHeaderFilename
;
2337 MingwModuleHandler::GetDefinitionDependencies (
2338 vector
<FileLocation
>& dependencies
) const
2340 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2341 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2343 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2344 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2345 string extension
= GetExtension ( sourceFile
);
2347 if (extension
== ".spec" || extension
== ".pspec")
2348 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2350 if (extension
== ".idl")
2352 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2353 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2358 enum DebugSupportType
2365 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2371 case DebugKernelMode
:
2372 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2376 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2383 module
.non_if_data
.libraries
.push_back(pLibrary
);
2387 MingwAddCRTLibrary( Module
&module
)
2389 const char * crtAttr
= module
.CRT
.c_str ();
2390 const char * crtLib
= NULL
;
2392 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2394 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2396 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2397 crtLib
= "libcntpr";
2398 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2403 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2405 if ( pLibrary
->importedModule
== NULL
)
2407 throw XMLInvalidBuildFileException (
2408 module
.node
.location
,
2409 "module '%s' trying to import non-existant C runtime module '%s'",
2410 module
.name
.c_str(),
2414 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2418 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2419 : MingwModuleHandler ( module_
)
2424 MingwBuildToolModuleHandler::Process ()
2426 GenerateBuildToolModuleTarget ();
2430 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2432 string
targetMacro ( GetTargetMacro (module
) );
2433 string objectsMacro
= GetObjectsMacro ( module
);
2434 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2435 string libsMacro
= GetLibsMacro ();
2439 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2442 if ( module
.cplusplus
)
2443 linker
= "${host_gpp}";
2445 linker
= "${host_gcc}";
2447 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2448 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2449 targetMacro
.c_str (),
2450 objectsMacro
.c_str (),
2451 linkDepsMacro
.c_str (),
2452 backend
->GetFullPath ( *target_file
).c_str () );
2453 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2454 fprintf ( fMakefile
,
2455 "\t%s %s -o $@ %s %s\n\n",
2457 GetLinkerMacro ().c_str (),
2458 objectsMacro
.c_str (),
2459 libsMacro
.c_str () );
2465 MingwKernelModuleHandler::MingwKernelModuleHandler (
2466 const Module
& module_
)
2468 : MingwModuleHandler ( module_
)
2473 MingwKernelModuleHandler::Process ()
2475 GenerateKernelModuleTarget ();
2479 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2481 string
targetMacro ( GetTargetMacro ( module
) );
2482 string workingDirectory
= GetWorkingDirectory ( );
2483 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2485 GenerateImportLibraryTargetIfNeeded ();
2487 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2491 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2493 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
2494 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2495 module
.baseaddress
.c_str () );
2497 GenerateLinkerCommand ( dependencies
,
2498 linkerParameters
+ " $(NTOSKRNL_SHARED)",
2503 GeneratePhonyTarget();
2508 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2509 const Module
& module_
)
2511 : MingwModuleHandler ( module_
)
2517 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2519 MingwAddCRTLibrary ( module
);
2520 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2524 MingwKernelModeDLLModuleHandler::Process ()
2526 GenerateKernelModeDLLModuleTarget ();
2530 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2532 string
targetMacro ( GetTargetMacro ( module
) );
2533 string workingDirectory
= GetWorkingDirectory ();
2534 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2536 GenerateImportLibraryTargetIfNeeded ();
2538 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2542 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2544 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2545 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2546 module
.baseaddress
.c_str () );
2547 GenerateLinkerCommand ( dependencies
,
2553 GeneratePhonyTarget();
2558 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2559 const Module
& module_
)
2561 : MingwModuleHandler ( module_
)
2566 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2568 MingwAddCRTLibrary ( module
);
2569 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2573 MingwNativeDLLModuleHandler::Process ()
2575 GenerateNativeDLLModuleTarget ();
2579 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2581 string
targetMacro ( GetTargetMacro (module
) );
2582 string workingDirectory
= GetWorkingDirectory ( );
2583 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2585 GenerateImportLibraryTargetIfNeeded ();
2587 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2591 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2593 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2594 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2595 module
.baseaddress
.c_str () );
2596 GenerateLinkerCommand ( dependencies
,
2602 GeneratePhonyTarget();
2607 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2608 const Module
& module_
)
2610 : MingwModuleHandler ( module_
)
2615 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2617 MingwAddCRTLibrary ( module
);
2618 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2622 MingwNativeCUIModuleHandler::Process ()
2624 GenerateNativeCUIModuleTarget ();
2628 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2630 string
targetMacro ( GetTargetMacro (module
) );
2631 string workingDirectory
= GetWorkingDirectory ( );
2632 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2634 GenerateImportLibraryTargetIfNeeded ();
2636 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2640 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2642 string linkerParameters
= ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2643 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2644 module
.baseaddress
.c_str () );
2645 GenerateLinkerCommand ( dependencies
,
2651 GeneratePhonyTarget();
2656 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2657 const Module
& module_
)
2659 : MingwModuleHandler ( module_
)
2663 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2664 const Module
& module_
)
2666 : MingwModuleHandler ( module_
)
2671 MingwAddImplicitLibraries( Module
&module
)
2675 if ( module
.type
!= Win32DLL
2676 && module
.type
!= Win32OCX
2677 && module
.type
!= Win32CUI
2678 && module
.type
!= Win32GUI
2679 && module
.type
!= Win32SCR
)
2684 if ( module
.isDefaultEntryPoint
)
2686 if ( module
.IsDLL () )
2688 //pLibrary = new Library ( module, "__mingw_dllmain" );
2689 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2693 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2694 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2698 pLibrary
= new Library ( module
, "mingw_common" );
2699 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2701 MingwAddCRTLibrary ( module
);
2702 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2706 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2708 MingwAddImplicitLibraries ( module
);
2712 MingwWin32DLLModuleHandler::Process ()
2714 GenerateWin32DLLModuleTarget ();
2718 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2720 string
targetMacro ( GetTargetMacro (module
) );
2721 string workingDirectory
= GetWorkingDirectory ( );
2722 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2724 GenerateImportLibraryTargetIfNeeded ();
2726 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2730 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2732 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2733 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2734 module
.baseaddress
.c_str () );
2735 GenerateLinkerCommand ( dependencies
,
2741 GeneratePhonyTarget();
2747 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2749 MingwAddImplicitLibraries ( module
);
2753 MingwWin32OCXModuleHandler::Process ()
2755 GenerateWin32OCXModuleTarget ();
2759 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2761 string
targetMacro ( GetTargetMacro (module
) );
2762 string workingDirectory
= GetWorkingDirectory ( );
2763 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2765 GenerateImportLibraryTargetIfNeeded ();
2767 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2771 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2773 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
2774 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2775 module
.baseaddress
.c_str () );
2776 GenerateLinkerCommand ( dependencies
,
2782 GeneratePhonyTarget();
2787 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2788 const Module
& module_
)
2790 : MingwModuleHandler ( module_
)
2795 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2797 MingwAddImplicitLibraries ( module
);
2801 MingwWin32CUIModuleHandler::Process ()
2803 GenerateWin32CUIModuleTarget ();
2807 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2809 string
targetMacro ( GetTargetMacro (module
) );
2810 string workingDirectory
= GetWorkingDirectory ( );
2811 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2813 GenerateImportLibraryTargetIfNeeded ();
2815 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2819 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2821 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2822 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2823 module
.baseaddress
.c_str () );
2824 GenerateLinkerCommand ( dependencies
,
2830 GeneratePhonyTarget();
2835 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2836 const Module
& module_
)
2838 : MingwModuleHandler ( module_
)
2843 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2845 MingwAddImplicitLibraries ( module
);
2849 MingwWin32GUIModuleHandler::Process ()
2851 GenerateWin32GUIModuleTarget ();
2855 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2857 string
targetMacro ( GetTargetMacro (module
) );
2858 string workingDirectory
= GetWorkingDirectory ( );
2859 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2861 GenerateImportLibraryTargetIfNeeded ();
2863 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
2867 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2869 string linkerParameters
= ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
2870 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
2871 module
.baseaddress
.c_str () );
2872 GenerateLinkerCommand ( dependencies
,
2878 GeneratePhonyTarget();
2883 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2884 const Module
& module_
)
2886 : MingwModuleHandler ( module_
)
2891 MingwBootLoaderModuleHandler::Process ()
2893 GenerateBootLoaderModuleTarget ();
2897 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2899 string
targetName ( module
.output
->name
);
2900 string
targetMacro ( GetTargetMacro (module
) );
2901 string workingDirectory
= GetWorkingDirectory ();
2902 FileLocation
junk_tmp ( TemporaryDirectory
,
2904 module
.name
+ ".junk.tmp" );
2905 CLEAN_FILE ( junk_tmp
);
2906 string objectsMacro
= GetObjectsMacro ( module
);
2907 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2911 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2913 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2914 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2915 targetMacro
.c_str (),
2916 objectsMacro
.c_str (),
2917 linkDepsMacro
.c_str (),
2918 backend
->GetFullPath ( *target_file
).c_str () );
2920 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2922 if (Environment::GetArch() == "arm")
2924 fprintf ( fMakefile
,
2925 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
2926 backend
->GetFullName ( junk_tmp
).c_str (),
2927 objectsMacro
.c_str (),
2928 linkDepsMacro
.c_str (),
2929 GetLinkerMacro ().c_str ());
2933 fprintf ( fMakefile
,
2934 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
2935 backend
->GetFullName ( junk_tmp
).c_str (),
2936 objectsMacro
.c_str (),
2937 linkDepsMacro
.c_str (),
2938 GetLinkerMacro ().c_str ());
2940 fprintf ( fMakefile
,
2941 "\t${objcopy} -O binary %s $@\n",
2942 backend
->GetFullName ( junk_tmp
).c_str () );
2943 GenerateBuildMapCode ( &junk_tmp
);
2944 fprintf ( fMakefile
,
2945 "\t-@${rm} %s 2>$(NUL)\n",
2946 backend
->GetFullName ( junk_tmp
).c_str () );
2952 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2953 const Module
& module_
)
2954 : MingwModuleHandler ( module_
)
2959 MingwBootProgramModuleHandler::Process ()
2961 GenerateBootProgramModuleTarget ();
2965 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2967 string
targetName ( module
.output
->name
);
2968 string
targetMacro ( GetTargetMacro (module
) );
2969 string workingDirectory
= GetWorkingDirectory ();
2970 FileLocation
junk_tmp ( TemporaryDirectory
,
2972 module
.name
+ ".junk.tmp" );
2973 FileLocation
junk_elf ( TemporaryDirectory
,
2975 module
.name
+ ".junk.elf" );
2976 FileLocation
junk_cpy ( TemporaryDirectory
,
2978 module
.name
+ ".junk.elf" );
2979 CLEAN_FILE ( junk_tmp
);
2980 CLEAN_FILE ( junk_elf
);
2981 CLEAN_FILE ( junk_cpy
);
2982 string objectsMacro
= GetObjectsMacro ( module
);
2983 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2984 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
2988 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
2990 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2991 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
2992 targetMacro
.c_str (),
2993 objectsMacro
.c_str (),
2994 linkDepsMacro
.c_str (),
2995 payload
->name
.c_str (),
2996 backend
->GetFullPath ( *target_file
).c_str () );
2998 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3000 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
3001 module
.buildtype
.c_str (),
3002 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
3003 backend
->GetFullName ( junk_cpy
).c_str () );
3005 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
3006 module
.buildtype
.c_str (),
3007 backend
->GetFullName ( junk_cpy
).c_str (),
3008 backend
->GetFullName ( junk_tmp
).c_str () );
3010 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3011 module
.buildtype
.c_str (),
3012 linkDepsMacro
.c_str (),
3013 backend
->GetFullName ( junk_tmp
).c_str (),
3014 backend
->GetFullName ( junk_elf
).c_str () );
3016 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
3017 module
.buildtype
.c_str (),
3018 backend
->GetFullName ( junk_elf
).c_str (),
3019 backend
->GetFullName ( *module
.output
) .c_str () );
3021 fprintf ( fMakefile
,
3022 "\t-@${rm} %s %s %s 2>$(NUL)\n",
3023 backend
->GetFullName ( junk_tmp
).c_str (),
3024 backend
->GetFullName ( junk_elf
).c_str (),
3025 backend
->GetFullName ( junk_cpy
).c_str () );
3031 MingwIsoModuleHandler::MingwIsoModuleHandler (
3032 const Module
& module_
)
3034 : MingwModuleHandler ( module_
)
3039 MingwIsoModuleHandler::Process ()
3041 GenerateIsoModuleTarget ();
3045 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
3046 const string
& bootcdDirectory
)
3048 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3050 const Module
& m
= *p
->second
;
3053 if ( m
.bootstrap
!= NULL
)
3055 FileLocation
targetFile ( OutputDirectory
,
3056 m
.bootstrap
->base
.length () > 0
3057 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3059 m
.bootstrap
->nameoncd
);
3060 OutputCopyCommand ( *m
.output
, targetFile
);
3066 MingwIsoModuleHandler::OutputCdfileCopyCommands (
3067 const string
& bootcdDirectory
)
3069 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3071 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3072 FileLocation
targetFile ( OutputDirectory
,
3073 cdfile
.target
->relative_path
.length () > 0
3074 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3076 cdfile
.target
->name
);
3077 OutputCopyCommand ( *cdfile
.source
, targetFile
);
3082 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
3083 const string
& bootcdDirectory
)
3085 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3087 const Module
& m
= *p
->second
;
3090 if ( m
.bootstrap
!= NULL
)
3092 FileLocation
targetDirectory ( OutputDirectory
,
3093 m
.bootstrap
->base
.length () > 0
3094 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
3097 out
.push_back ( targetDirectory
);
3103 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
3104 const string
& bootcdDirectory
)
3106 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3108 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3109 FileLocation
targetDirectory ( OutputDirectory
,
3110 cdfile
.target
->relative_path
.length () > 0
3111 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
3114 out
.push_back( targetDirectory
);
3119 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
3120 const string
& bootcdDirectory
)
3122 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
3123 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
3127 MingwIsoModuleHandler::GetBootstrapCdFiles (
3128 vector
<FileLocation
>& out
) const
3130 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3132 const Module
& m
= *p
->second
;
3135 if ( m
.bootstrap
!= NULL
)
3137 out
.push_back ( *m
.output
);
3143 MingwIsoModuleHandler::GetNonModuleCdFiles (
3144 vector
<FileLocation
>& out
) const
3146 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
3148 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
3149 out
.push_back ( *cdfile
.source
);
3154 MingwIsoModuleHandler::GetCdFiles (
3155 vector
<FileLocation
>& out
) const
3157 GetBootstrapCdFiles ( out
);
3158 GetNonModuleCdFiles ( out
);
3162 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
3164 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
3165 string bootcdDirectory
= "cd";
3166 FileLocation
bootcd ( OutputDirectory
,
3169 FileLocation
bootcdReactos ( OutputDirectory
,
3170 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
3172 vector
<FileLocation
> vSourceFiles
, vCdFiles
;
3173 vector
<FileLocation
> vCdDirectories
;
3176 FileLocation
srcunattend ( SourceDirectory
,
3177 "boot" + sSep
+ "bootdata" + sSep
+ "bootcdregtest",
3179 FileLocation
tarunattend ( bootcdReactos
.directory
,
3180 bootcdReactos
.relative_path
,
3182 if (module
.type
== IsoRegTest
)
3183 vSourceFiles
.push_back ( srcunattend
);
3186 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3190 throw InvalidOperationException ( module
.node
.location
.c_str(),
3192 "Invalid bootsector. module '%s' requires <bootsector>",
3193 module
.name
.c_str ());
3196 const FileLocation
*isoboot
= bootModule
->output
;
3197 vSourceFiles
.push_back ( *isoboot
);
3199 // prepare reactos.dff and reactos.inf
3200 FileLocation
reactosDff ( SourceDirectory
,
3201 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
3203 FileLocation
reactosInf ( bootcdReactos
.directory
,
3204 bootcdReactos
.relative_path
,
3207 vSourceFiles
.push_back ( reactosDff
);
3210 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3211 Iso/LiveIso outputs are generated in code base root
3213 string IsoName
= module
.output
->name
;
3215 string sourceFiles
= v2s ( backend
, vSourceFiles
, 5 );
3218 GetCdDirectories ( vCdDirectories
, bootcdDirectory
);
3219 GetCdFiles ( vCdFiles
);
3220 string cdDirectories
= "";//v2s ( vCdDirectories, 5 );
3221 string cdFiles
= v2s ( backend
, vCdFiles
, 5 );
3223 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3224 module
.name
.c_str ());
3225 fprintf ( fMakefile
,
3226 "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) %s\n",
3227 module
.name
.c_str (),
3228 backend
->GetFullName ( *isoboot
).c_str (),
3229 sourceFiles
.c_str (),
3231 cdDirectories
.c_str () );
3232 fprintf ( fMakefile
,
3233 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
3234 backend
->GetFullName ( reactosDff
).c_str (),
3235 backend
->GetFullPath ( bootcdReactos
).c_str () );
3236 fprintf ( fMakefile
,
3237 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
3238 backend
->GetFullName ( reactosDff
).c_str (),
3239 backend
->GetFullName ( reactosInf
).c_str (),
3240 backend
->GetFullPath ( bootcdReactos
).c_str ());
3241 fprintf ( fMakefile
,
3242 "\t-@${rm} %s 2>$(NUL)\n",
3243 backend
->GetFullName ( reactosInf
).c_str () );
3244 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
3245 OutputCdfileCopyCommands ( bootcdDirectory
);
3247 if (module
.type
== IsoRegTest
)
3248 OutputCopyCommand ( srcunattend
, tarunattend
);
3250 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3251 fprintf ( fMakefile
,
3252 "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n",
3253 backend
->GetFullName ( *isoboot
).c_str (),
3254 backend
->GetFullPath ( bootcd
).c_str (),
3256 fprintf ( fMakefile
,
3261 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
3262 const Module
& module_
)
3264 : MingwModuleHandler ( module_
)
3269 MingwLiveIsoModuleHandler::Process ()
3271 GenerateLiveIsoModuleTarget ();
3275 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
3277 FileLocation
dir ( OutputDirectory
,
3280 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
3284 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
3285 string
& reactosDirectory
)
3287 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
3289 const Module
& m
= *p
->second
;
3294 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
3295 FileLocation
destination ( OutputDirectory
,
3296 m
.install
->relative_path
.length () > 0
3297 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
3298 : livecdDirectory
+ sSep
+ reactosDirectory
,
3300 OutputCopyCommand ( *aliasedModule
.output
,
3307 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
3308 string
& reactosDirectory
)
3310 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
3312 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
3313 FileLocation
target ( OutputDirectory
,
3314 installfile
.target
->relative_path
.length () > 0
3315 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
3316 : livecdDirectory
+ sSep
+ reactosDirectory
,
3317 installfile
.target
->name
);
3318 OutputCopyCommand ( *installfile
.source
, target
);
3323 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
3325 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
3326 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
3327 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
3328 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
3329 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
3330 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
3332 FileLocation
livecdIni ( SourceDirectory
,
3333 "boot" + sSep
+ "bootdata",
3335 FileLocation
destination ( OutputDirectory
,
3338 OutputCopyCommand ( livecdIni
,
3343 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
3345 FileLocation
freeldr ( OutputDirectory
,
3346 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
3348 FileLocation
destination ( OutputDirectory
,
3349 livecdDirectory
+ sSep
+ "loader",
3351 OutputCopyCommand ( freeldr
,
3356 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
3358 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
3359 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
3360 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
3362 fprintf ( fMakefile
,
3363 "\t$(ECHO_MKHIVE)\n" );
3364 fprintf ( fMakefile
,
3365 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
3366 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3367 cSep
, cSep
, cSep
, cSep
);
3371 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3373 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3374 string livecdDirectory
= module
.name
;
3375 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3380 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3384 throw InvalidOperationException ( module
.node
.location
.c_str(),
3386 "Invalid bootsector. module '%s' requires <bootsector>",
3387 module
.name
.c_str ());
3390 const FileLocation
*isoboot
= bootModule
->output
;
3393 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3394 Iso/LiveIso outputs are generated in code base root
3396 IsoName
= module
.output
->name
;
3398 string reactosDirectory
= "reactos";
3399 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3400 FileLocation
livecdReactos ( OutputDirectory
,
3401 livecdReactosNoFixup
,
3403 CLEAN_FILE ( livecdReactos
);
3405 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3406 module
.name
.c_str ());
3407 fprintf ( fMakefile
,
3408 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
3409 module
.name
.c_str (),
3410 backend
->GetFullName ( *isoboot
) .c_str (),
3411 backend
->GetFullPath ( livecdReactos
).c_str () );
3412 OutputModuleCopyCommands ( livecdDirectory
,
3414 OutputNonModuleCopyCommands ( livecdDirectory
,
3416 OutputProfilesDirectoryCommands ( livecdDirectory
);
3417 OutputLoaderCommands ( livecdDirectory
);
3418 OutputRegistryCommands ( livecdDirectory
);
3419 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3420 fprintf ( fMakefile
,
3421 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3422 backend
->GetFullName( *isoboot
).c_str (),
3423 backend
->GetFullPath ( livecd
).c_str (),
3425 fprintf ( fMakefile
,
3430 MingwTestModuleHandler::MingwTestModuleHandler (
3431 const Module
& module_
)
3433 : MingwModuleHandler ( module_
)
3438 MingwTestModuleHandler::Process ()
3440 GenerateTestModuleTarget ();
3443 /* caller needs to delete the returned object */
3445 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3447 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3448 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3449 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3453 MingwTestModuleHandler::GenerateTestModuleTarget ()
3455 string
targetMacro ( GetTargetMacro ( module
) );
3456 string workingDirectory
= GetWorkingDirectory ( );
3457 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3459 GenerateImportLibraryTargetIfNeeded ();
3461 if ( module
.non_if_data
.compilationUnits
.size () > 0 )
3465 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
3467 string linkerParameters
= ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
3468 module
.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
3469 module
.baseaddress
.c_str () );
3470 GenerateLinkerCommand ( dependencies
,
3476 GeneratePhonyTarget();
3481 MingwAliasModuleHandler::MingwAliasModuleHandler (
3482 const Module
& module_
)
3484 : MingwModuleHandler ( module_
)
3489 MingwAliasModuleHandler::Process ()
3494 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3495 const Module
& module_
)
3497 : MingwModuleHandler ( module_
)
3502 MingwCabinetModuleHandler::Process ()
3504 string
targetMacro ( GetTargetMacro (module
) );
3508 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3509 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3510 fprintf ( fMakefile
, "%s: $(CABMAN_TARGET) | %s\n",
3511 targetMacro
.c_str (),
3512 backend
->GetFullPath ( *target_file
).c_str () );
3514 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3515 fprintf ( fMakefile
,
3516 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3517 targetMacro
.c_str (),
3518 module
.name
.c_str());
3521 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3522 const Module
& module_
)
3524 : MingwModuleHandler ( module_
)
3529 MingwElfExecutableModuleHandler::Process ()
3531 string
targetName ( module
.output
->name
);
3532 string
targetMacro ( GetTargetMacro (module
) );
3533 string workingDirectory
= GetWorkingDirectory ();
3534 string objectsMacro
= GetObjectsMacro ( module
);
3535 string linkDepsMacro
= GetLinkingDependenciesMacro ();
3536 string libsMacro
= GetLibsMacro ();
3540 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3541 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3542 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3543 targetMacro
.c_str (),
3544 objectsMacro
.c_str (),
3545 linkDepsMacro
.c_str (),
3546 backend
->GetFullPath ( *target_file
).c_str () );
3548 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3550 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g -o %s\n",
3551 module
.buildtype
.c_str(),
3552 objectsMacro
.c_str(),
3554 targetMacro
.c_str () );