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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
);
68 return ssprintf ( "$(%s)", s
.c_str() );
72 MingwModuleHandler::MingwModuleHandler (
73 const Module
& module_
)
80 MingwModuleHandler::~MingwModuleHandler()
85 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
91 MingwModuleHandler::SetMakefile ( FILE* f
)
97 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
102 /*static*/ const FileLocation
*
103 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
105 switch ( file
->directory
)
107 case SourceDirectory
:
109 case IntermediateDirectory
:
110 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
112 case OutputDirectory
:
113 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
115 case InstallDirectory
:
116 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
119 throw InvalidOperationException ( __FILE__
,
121 "Invalid directory %d.",
128 /* caller needs to delete the returned object */
130 MingwModuleHandler::GetTargetFilename (
131 const Module
& module
,
132 string_list
* pclean_files
)
134 FileLocation
*target
= new FileLocation ( *module
.output
);
137 string_list
& clean_files
= *pclean_files
;
138 CLEAN_FILE ( *target
);
143 /* caller needs to delete the returned object */
145 MingwModuleHandler::GetImportLibraryFilename (
146 const Module
& module
,
147 string_list
* pclean_files
,
150 FileLocation
*target
;
152 if (module
.HasImportLibrary())
156 target
= new FileLocation ( *module
.delayImportLibrary
->target
);
159 target
= new FileLocation ( *module
.importLibrary
->target
);
162 target
= new FileLocation ( *module
.dependency
);
166 string_list
& clean_files
= *pclean_files
;
167 CLEAN_FILE ( *target
);
172 /* caller needs to delete the returned object */
174 MingwModuleHandler::InstanciateHandler (
175 const Module
& module
,
176 MingwBackend
* backend
)
178 MingwModuleHandler
* handler
;
179 switch ( module
.type
)
182 case HostStaticLibrary
:
190 case EmbeddedTypeLib
:
192 handler
= new MingwModuleHandler( module
);
195 handler
= new MingwBuildToolModuleHandler ( module
);
198 handler
= new MingwKernelModuleHandler ( module
);
201 handler
= new MingwNativeCUIModuleHandler ( module
);
204 handler
= new MingwWin32CUIModuleHandler ( module
);
208 handler
= new MingwWin32GUIModuleHandler ( module
);
212 case KernelModeDriver
:
213 handler
= new MingwKernelModeDLLModuleHandler ( module
);
216 handler
= new MingwNativeDLLModuleHandler ( module
);
219 handler
= new MingwWin32DLLModuleHandler ( module
);
222 handler
= new MingwWin32OCXModuleHandler ( module
);
225 handler
= new MingwBootLoaderModuleHandler ( module
);
228 handler
= new MingwBootProgramModuleHandler ( module
);
231 handler
= new MingwIsoModuleHandler ( module
);
234 handler
= new MingwLiveIsoModuleHandler ( module
);
237 handler
= new MingwTestModuleHandler ( module
);
240 handler
= new MingwAliasModuleHandler ( module
);
243 handler
= new MingwCabinetModuleHandler ( module
);
246 handler
= new MingwElfExecutableModuleHandler ( module
);
249 throw UnknownModuleTypeException (
250 module
.node
.location
,
258 MingwModuleHandler::GetWorkingDirectory () const
264 MingwModuleHandler::GetBasename ( const string
& filename
) const
266 size_t index
= filename
.find_last_of ( '.' );
267 if ( index
!= string::npos
)
268 return filename
.substr ( 0, index
);
273 MingwModuleHandler::GetCompilationUnitDependencies (
274 const CompilationUnit
& compilationUnit
) const
276 if ( compilationUnit
.GetFiles ().size () <= 1 )
278 vector
<string
> sourceFiles
;
279 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
281 const File
& file
= *compilationUnit
.GetFiles ()[i
];
282 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
284 return string ( " " ) + backend
->v2s ( sourceFiles
, 10 );
287 /* caller needs to delete the returned object */
289 MingwModuleHandler::GetModuleArchiveFilename () const
291 if ( IsStaticLibrary ( module
) )
292 return GetTargetFilename ( module
, NULL
);
297 MingwModuleHandler::ReferenceObjects (
298 const Module
& module
)
300 if ( module
.type
== ObjectLibrary
)
302 if ( module
.type
== RpcServer
)
304 if ( module
.type
== RpcClient
)
306 if ( module
.type
== RpcProxy
)
308 if ( module
.type
== IdlHeader
)
310 if ( module
.type
== IdlInterface
)
312 if ( module
.type
== MessageHeader
)
318 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
319 const FileLocation
& destination
)
321 fprintf ( fMakefile
, "# OUTPUT COPY COMMAND\n" );
325 "\t${cp} \"%s\" \"%s\" 1>$(NUL)\n",
326 backend
->GetFullName ( source
).c_str (),
327 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
331 MingwModuleHandler::OutputCopyCommandSingle ( const FileLocation
& source
,
332 const FileLocation
& destination
)
336 backend
->GetFullNamePrefixSpaces ( *PassThruCacheDirectory ( &destination
) ).c_str (),
337 backend
->GetFullNamePrefixSpaces ( source
).c_str () );
341 "\t${cp} \"%s\" \"%s\" 1>$(NUL)\n",
342 backend
->GetFullName ( source
).c_str (),
343 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
347 MingwModuleHandler::GetImportLibraryDependency (
348 const Module
& importedModule
,
352 if ( ReferenceObjects ( importedModule
) )
354 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
357 dep
= GetTargetMacro ( importedModule
);
358 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
360 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
361 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
362 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
363 if ( GetExtension ( *objectFilename
) == ".h" )
364 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
365 else if ( GetExtension ( *objectFilename
) == ".rc" )
366 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
367 delete objectFilename
;
372 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
, delayimp
);
373 dep
= backend
->GetFullName ( *library_target
);
374 delete library_target
;
377 if ( IsStaticLibrary ( importedModule
) || importedModule
.type
== ObjectLibrary
)
379 const std::vector
<Library
*>& libraries
= importedModule
.non_if_data
.libraries
;
381 for ( size_t i
= 0; i
< libraries
.size (); ++ i
)
384 dep
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
, libraries
[i
]->delayimp
);
392 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
393 string_list
& targets
)
395 if ( dependencyModule
.invocations
.size () > 0 )
397 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
399 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
400 invoke
.GetTargets ( targets
);
404 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
, false ) );
408 MingwModuleHandler::GetModuleDependencies (
409 string_list
& dependencies
)
411 size_t iend
= module
.dependencies
.size ();
416 for ( size_t i
= 0; i
< iend
; i
++ )
418 const Dependency
& dependency
= *module
.dependencies
[i
];
419 const Module
& dependencyModule
= *dependency
.dependencyModule
;
420 GetTargets ( dependencyModule
,
423 vector
<FileLocation
> v
;
424 GetDefinitionDependencies ( v
);
426 for ( size_t i
= 0; i
< v
.size (); i
++ )
428 const FileLocation
& file
= v
[i
];
429 dependencies
.push_back ( backend
->GetFullName ( file
) );
433 /* caller needs to delete the returned object */
435 MingwModuleHandler::GetObjectFilename (
436 const FileLocation
* sourceFile
,
437 const Module
& module
) const
439 DirectoryLocation destination_directory
;
441 string extension
= GetExtension ( *sourceFile
);
443 if ( module
.type
== BootSector
)
444 return new FileLocation ( *module
.output
);
445 else if (extension
== ".rc")
446 newExtension
= "_" + module
.name
+ ".coff";
447 else if (extension
== ".mc")
448 newExtension
= ".rc";
449 else if (extension
== ".idl")
451 if ( module
.type
== RpcServer
)
452 newExtension
= "_s.o";
453 else if ( module
.type
== RpcClient
)
454 newExtension
= "_c.o";
455 else if ( module
.type
== RpcProxy
)
456 newExtension
= "_p.o";
457 else if ( module
.type
== IdlInterface
)
458 newExtension
= "_i.o";
463 newExtension
= "_" + module
.name
+ ".o";
465 if ( module
.type
== BootSector
)
466 destination_directory
= OutputDirectory
;
468 destination_directory
= IntermediateDirectory
;
470 const FileLocation
*obj_file
= new FileLocation(
471 destination_directory
,
472 sourceFile
->relative_path
,
473 ReplaceExtension ( sourceFile
->name
, newExtension
) );
474 PassThruCacheDirectory ( obj_file
);
480 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
482 return module
.name
+ "_clean";
486 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
488 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
490 Library
& library
= *module
.non_if_data
.libraries
[i
];
491 if ( library
.importedModule
->type
== ObjectLibrary
)
492 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
497 MingwModuleHandler::GenerateCleanTarget () const
499 if ( module
.type
== Alias
)
502 fprintf ( fMakefile
, "# CLEAN TARGET\n" );
504 ".PHONY: %s_clean\n",
505 module
.name
.c_str() );
506 vector
<string
> referencedModuleNames
;
507 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
510 GetModuleCleanTarget ( module
).c_str(),
511 backend
->v2s ( referencedModuleNames
, 10 ).c_str () );
512 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
514 if ( ( i
+ 1 ) % 10 == 9 )
515 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
516 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
518 fprintf ( fMakefile
, " 2>$(NUL)\n" );
520 // Clean files generated by external rules
521 fprintf ( fMakefile
, "\t-@${rm} $(%s_CLEANFILES) 2>$(NUL)\n", module
.name
.c_str() );
523 if( ProxyMakefile::GenerateProxyMakefile(module
) )
525 DirectoryLocation root
;
527 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
528 root
= SourceDirectory
;
530 root
= OutputDirectory
;
532 FileLocation
proxyMakefile ( root
,
533 module
.output
->relative_path
,
535 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
536 backend
->GetFullName ( proxyMakefile
).c_str () );
539 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
543 MingwModuleHandler::GenerateInstallTarget () const
545 if ( !module
.install
)
547 fprintf ( fMakefile
, "# INSTALL TARGET\n" );
548 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
551 module
.name
.c_str (),
552 backend
->GetFullName ( *module
.install
).c_str () );
556 MingwModuleHandler::GenerateDependsTarget () const
558 fprintf ( fMakefile
, "# DEPENDS TARGET\n" );
560 ".PHONY: %s_depends\n",
561 module
.name
.c_str() );
563 "%s_depends: $(RBUILD_TARGET)\n",
564 module
.name
.c_str () );
566 "\t$(ECHO_RBUILD)\n" );
568 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
569 module
.name
.c_str () );
573 const char * const CompilerPrefixTable
[ CompilerTypesCount
] =
585 MingwModuleHandler::GenerateParameters (
587 const char* assignmentOperation
,
588 const IfableData
& data
)
590 for ( unsigned type
= CompilerTypeCC
; type
< CompilerTypesCount
; ++ type
)
592 CompilerType compiler
= static_cast < CompilerType
> ( type
);
595 std::string includes
= GenerateIncludeParametersFromVector ( data
.includes
, compiler
);
597 if ( includes
.size() )
600 "%s_%sINCLUDES%s%s\n",
602 CompilerPrefixTable
[ compiler
],
608 std::string defines
= GenerateDefineParametersFromVector ( data
.defines
, compiler
);
610 if ( defines
.size() )
613 "%s_%sDEFINES%s%s\n",
615 CompilerPrefixTable
[ compiler
],
621 std::string flags
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, compiler
);
628 CompilerPrefixTable
[ compiler
],
636 MingwModuleHandler::GenerateGccDefineParametersFromVector (
637 const vector
<Define
*>& defines
,
638 set
<string
>& used_defs
)
642 for ( size_t i
= 0; i
< defines
.size (); i
++ )
644 Define
& define
= *defines
[i
];
645 if (used_defs
.find(define
.name
) != used_defs
.end())
649 if (parameters
.length () > 0)
652 parameters
+= define
.name
;
654 if (parameters
.length () > 0)
656 if (define
.arguments
.length ())
657 parameters
+= "$(QT)";
659 parameters
+= define
.name
;
660 parameters
+= define
.arguments
;
661 if (define
.value
.length () > 0)
664 parameters
+= define
.value
;
666 if (define
.arguments
.length ())
667 parameters
+= "$(QT)";
668 used_defs
.insert(used_defs
.begin(),define
.name
);
674 MingwModuleHandler::GenerateDefineParametersFromVector (
675 const std::vector
<Define
*>& defines
,
676 CompilerType compiler
)
680 for ( size_t i
= 0; i
< defines
.size (); i
++ )
682 Define
& define
= *defines
[i
];
683 if (!define
.IsCompilerSet (compiler
))
687 if (parameters
.length () > 0)
690 parameters
+= define
.name
;
692 if (parameters
.length () > 0)
694 if (define
.arguments
.length ())
695 parameters
+= "$(QT)";
697 parameters
+= define
.name
;
698 parameters
+= define
.arguments
;
699 if (define
.value
.length () > 0)
702 parameters
+= define
.value
;
704 if (define
.arguments
.length ())
705 parameters
+= "$(QT)";
711 MingwModuleHandler::ConcatenatePaths (
713 const string
& path2
) const
715 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
717 if ( path1
[path1
.length ()] == cSep
)
718 return path1
+ path2
;
720 return path1
+ cSep
+ path2
;
724 MingwModuleHandler::GenerateIncludeParametersFromVector ( const vector
<Include
*>& includes
, const CompilerType type
)
726 string parameters
, path_prefix
;
727 for ( size_t i
= 0; i
< includes
.size (); i
++ )
729 Include
& include
= *includes
[i
];
730 if ( include
.IsCompilerSet( type
) )
731 parameters
+= " -I" + backend
->GetFullPath ( *include
.directory
);
737 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
)
740 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
742 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
743 if ( compilerFlag
.IsCompilerSet( type
) )
744 parameters
+= " " + compilerFlag
.flag
;
750 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
753 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
755 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
756 if ( parameters
.length () > 0 )
758 parameters
+= linkerFlag
.flag
;
764 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
765 const vector
<Library
*>& libraries
)
767 string
dependencies ( "" );
769 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
771 if ( wrap_count
++ == 5 )
772 dependencies
+= " \\\n\t\t", wrap_count
= 0;
773 else if ( dependencies
.size () > 0 )
775 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
, libraries
[i
]->delayimp
);
781 MingwModuleHandler::GenerateLinkerParameters () const
783 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
787 MingwModuleHandler::GenerateMacros (
788 const char* assignmentOperation
,
789 const IfableData
& data
,
790 const vector
<LinkerFlag
*>* linkerFlags
,
791 set
<const Define
*>& used_defs
)
793 if ( linkerFlags
!= NULL
)
795 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
796 if ( linkerParameters
.size () > 0 )
801 linkerflagsMacro
.c_str (),
803 linkerParameters
.c_str() );
807 if ( data
.libraries
.size () > 0 )
809 // Check if host and target modules are not mixed up
810 HostType current
= ModuleHandlerInformations
[module
.type
].DefaultHost
;
811 std::vector
<Library
*>::const_iterator it
;
812 for ( it
= data
.libraries
.begin(); it
!= data
.libraries
.end(); ++it
)
814 HostType imported
= ModuleHandlerInformations
[(*it
)->importedModule
->type
].DefaultHost
;
815 if (current
!= imported
)
817 throw InvalidOperationException ( __FILE__
,
819 "Module '%s' imports module '%s', which is not of the right type",
820 module
.name
.c_str (),
821 (*it
)->importedModule
->name
.c_str () );
825 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
826 if ( deps
.size () > 0 )
839 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
841 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
842 delete compilationUnits
[i
];
846 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
851 MingwModuleHandler::GenerateSourceMacros (
852 const IfableData
& data
)
856 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
857 vector
<const FileLocation
*> headers
;
858 if ( compilationUnits
.size () > 0 )
863 sourcesMacro
.c_str () );
864 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
866 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
867 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
871 ( i
%10 == 9 ? " \\\n\t" : " " ),
872 backend
->GetFullName ( compilationName
).c_str () );
874 fprintf ( fMakefile
, "\n" );
877 vector
<CompilationUnit
*> sourceCompilationUnits
;
878 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
879 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
881 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
885 sourcesMacro
.c_str(),
886 backend
->GetFullName ( compilationName
).c_str () );
888 CleanupCompilationUnitVector ( sourceCompilationUnits
);
892 MingwModuleHandler::GenerateObjectMacros (
893 const IfableData
& data
)
896 const char* assignmentOperation
= "=";
898 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
899 vector
<const FileLocation
*> headers
;
900 vector
<const FileLocation
*> mcheaders
;
901 vector
<const FileLocation
*> mcresources
;
902 if ( compilationUnits
.size () > 0 )
904 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
906 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
907 if ( compilationUnit
.IsFirstFile () )
909 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
910 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
913 objectsMacro
.c_str(),
914 backend
->GetFullName ( *object_file
).c_str () );
916 assignmentOperation
= "+=";
923 objectsMacro
.c_str (),
924 assignmentOperation
);
925 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
927 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
928 if ( !compilationUnit
.IsFirstFile () )
930 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
931 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
932 if ( GetExtension ( *objectFilename
) == ".h" )
933 headers
.push_back ( objectFilename
);
934 else if ( GetExtension ( *objectFilename
) == ".rc" )
936 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
937 mcheaders
.push_back ( headerFilename
);
938 mcresources
.push_back ( objectFilename
);
945 ( i
%10 == 9 ? " \\\n\t" : " " ),
946 backend
->GetFullName ( *objectFilename
).c_str () );
947 delete objectFilename
;
951 fprintf ( fMakefile
, "\n" );
953 if ( headers
.size () > 0 )
958 module
.name
.c_str (),
959 assignmentOperation
);
960 for ( i
= 0; i
< headers
.size (); i
++ )
965 ( i
%10 == 9 ? " \\\n\t" : " " ),
966 backend
->GetFullName ( *headers
[i
] ).c_str () );
969 fprintf ( fMakefile
, "\n" );
972 if ( mcheaders
.size () > 0 )
977 module
.name
.c_str (),
978 assignmentOperation
);
979 for ( i
= 0; i
< mcheaders
.size (); i
++ )
984 ( i
%10 == 9 ? " \\\n\t" : " " ),
985 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
988 fprintf ( fMakefile
, "\n" );
991 if ( mcresources
.size () > 0 )
996 module
.name
.c_str (),
997 assignmentOperation
);
998 for ( i
= 0; i
< mcresources
.size (); i
++ )
1003 ( i
%10 == 9 ? " \\\n\t" : " " ),
1004 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
1005 delete mcresources
[i
];
1007 fprintf ( fMakefile
, "\n" );
1010 vector
<CompilationUnit
*> sourceCompilationUnits
;
1011 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1012 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1014 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1015 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1019 objectsMacro
.c_str(),
1020 backend
->GetFullName ( *object_file
).c_str () );
1023 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1025 if ( module
.IsSpecDefinitionFile() )
1027 const FileLocation
*stubs_file
= new FileLocation(
1028 IntermediateDirectory
,
1029 module
.importLibrary
->source
->relative_path
,
1030 ReplaceExtension ( module
.importLibrary
->source
->name
, "_" + module
.name
+ ".stubs.o" ) );
1035 objectsMacro
.c_str(),
1036 backend
->GetFullName ( *stubs_file
).c_str () );
1041 if ( module
.type
== RpcProxy
)
1043 const FileLocation
*dlldata_file
= GetDlldataFilename();
1048 objectsMacro
.c_str(),
1049 ReplaceExtension ( backend
->GetFullName ( *dlldata_file
), ".o" ).c_str() );
1051 delete dlldata_file
;
1056 MingwModuleHandler::GetDlldataFilename() const
1058 std::string dlldata_path
= "";
1059 size_t dlldata_path_len
= module
.xmlbuildFile
.find_last_of(cSep
);
1061 if ( dlldata_path_len
!= std::string::npos
&& dlldata_path_len
!= 0 )
1062 dlldata_path
= module
.xmlbuildFile
.substr(0, dlldata_path_len
);
1064 return new FileLocation( IntermediateDirectory
, dlldata_path
, module
.name
+ ".dlldata.c" );
1068 MingwModuleHandler::GetPrecompiledHeaderPath () const
1070 if ( !module
.pch
|| !use_pch
)
1072 return new FileLocation ( IntermediateDirectory
,
1073 module
.pch
->file
->relative_path
,
1074 ".gch_" + module
.name
);
1078 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1080 if ( !module
.pch
|| !use_pch
)
1082 return new FileLocation ( IntermediateDirectory
,
1083 module
.pch
->file
->relative_path
+ "/.gch_" + module
.name
,
1084 module
.pch
->file
->name
+ ".gch" );
1087 Rule
windresRule ( "$(eval $(call RBUILD_WRC_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1088 "$(intermediate_path_unique).coff",
1089 "$(intermediate_path_unique).res",
1090 "$(intermediate_path_unique).res.d",
1091 "$(intermediate_dir)$(SEP)", NULL
);
1092 Rule
winebuildPRule ( "$(eval $(call RBUILD_WINEBUILD_WITH_CPP_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags),$(module_dllname)))\n",
1093 "$(intermediate_path_unique).spec",
1094 "$(intermediate_path_unique).spec.d",
1095 "$(intermediate_path_unique).auto.def",
1096 "$(intermediate_path_unique).stubs.c",
1097 "$(intermediate_path_unique).stubs.o",
1098 "$(intermediate_path_unique).stubs.o.d",
1099 "$(intermediate_dir)$(SEP)", NULL
);
1100 Rule
winebuildRule ( "$(eval $(call RBUILD_WINEBUILD_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags),$(module_dllname)))\n",
1101 "$(intermediate_path_unique).auto.def",
1102 "$(intermediate_path_unique).stubs.c",
1103 "$(intermediate_path_unique).stubs.o",
1104 "$(intermediate_path_unique).stubs.o.d",
1105 "$(intermediate_dir)$(SEP)", NULL
);
1106 Rule
gasRule ( "$(eval $(call RBUILD_GAS_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1107 "$(intermediate_path_unique).o",
1108 "$(intermediate_path_unique).o.d", NULL
);
1109 Rule
gccRule ( "$(eval $(call RBUILD_CC_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1110 "$(intermediate_path_unique).o",
1111 "$(intermediate_path_unique).o.d", NULL
);
1112 Rule
gccHostRule ( "$(eval $(call RBUILD_HOST_GCC_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1113 "$(intermediate_path_unique).o", NULL
);
1114 Rule
gppRule ( "$(eval $(call RBUILD_CXX_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1115 "$(intermediate_path_unique).o",
1116 "$(intermediate_path_unique).o.d", NULL
);
1117 Rule
gppHostRule ( "$(eval $(call RBUILD_HOST_GPP_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1118 "$(intermediate_path_unique).o", NULL
);
1119 Rule
widlHeaderRule ( "$(eval $(call RBUILD_WIDL_HEADER_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1120 "$(intermediate_path_noext).h",
1121 "$(intermediate_dir)$(SEP)", NULL
);
1122 Rule
widlServerRule ( "$(eval $(call RBUILD_WIDL_SERVER_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1123 "$(intermediate_path_noext)_s.h",
1124 "$(intermediate_path_noext)_s.c",
1125 "$(intermediate_path_noext)_s.o",
1126 "$(intermediate_dir)$(SEP)", NULL
);
1127 Rule
widlClientRule ( "$(eval $(call RBUILD_WIDL_CLIENT_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1128 "$(intermediate_path_noext)_c.h",
1129 "$(intermediate_path_noext)_c.c",
1130 "$(intermediate_path_noext)_c.o",
1131 "$(intermediate_dir)$(SEP)", NULL
);
1132 Rule
widlProxyRule ( "$(eval $(call RBUILD_WIDL_PROXY_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1133 "$(intermediate_path_noext)_p.h",
1134 "$(intermediate_path_noext)_p.c",
1135 "$(intermediate_path_noext)_p.o",
1136 "$(intermediate_dir)$(SEP)", NULL
);
1137 Rule
widlInterfaceRule ( "$(eval $(call RBUILD_WIDL_INTERFACE_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1138 "$(intermediate_path_noext)_i.c",
1139 "$(intermediate_path_noext)_i.o",
1140 "$(intermediate_dir)$(SEP)", NULL
);
1141 Rule
widlDlldataRule ( "$(eval $(call RBUILD_WIDL_DLLDATA_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags),$(bare_dependencies)))\n",
1142 "$(intermediate_path_noext).o", NULL
);
1143 Rule
widlTlbRule ( "$(eval $(call RBUILD_WIDL_TLB_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1144 "$(intermediate_dir)$(SEP)", NULL
);
1145 Rule
pchRule ( "$(eval $(call RBUILD_CC_PCH_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1146 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch",
1147 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch.d",
1148 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)", NULL
);
1149 Rule
pchCxxRule ( "$(eval $(call RBUILD_CXX_PCH_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1150 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch",
1151 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch.d",
1152 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)", NULL
);
1153 Rule
bootRule ( "$(eval $(call RBUILD_NASM,$(module_name),$(source),$(dependencies),,$(module_output)))\n",
1155 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1156 Rule
nasmRule ( "$(eval $(call RBUILD_NASM,$(module_name),$(source),$(dependencies),,$(intermediate_path_unique).o))\n",
1157 "$(intermediate_path_unique).o",
1158 "$(intermediate_dir)$(SEP)", NULL
);
1160 /* TODO: move these to rules.mak */
1161 Rule
wmcRule ( "$(intermediate_path_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(wmc_TARGET) $(source) | $(intermediate_dir)\n"
1163 "\t$(Q)$(wmc_TARGET) -i -H $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h -o $(intermediate_path_noext).rc $(source)\n",
1164 "$(intermediate_path_noext).rc",
1165 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1166 "$(intermediate_dir)$(SEP)", NULL
);
1167 /* TODO: if possible, move these to rules.mak */
1168 Rule
arRule1 ( "$(intermediate_path_noext).a: $($(module_name)_OBJS) $(dependencies) | $(intermediate_dir)\n",
1169 "$(intermediate_path_noext).a",
1170 "$(intermediate_dir)$(SEP)", NULL
);
1171 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1172 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1174 Rule
arHostRule2 ( "\t$(ECHO_HOSTAR)\n"
1175 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1178 Rule
emptyRule ( "", NULL
);
1181 MingwModuleHandler::GenerateGccCommand (
1182 const FileLocation
* sourceFile
,
1184 const string
& extraDependencies
)
1186 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1187 string dependencies
= extraDependencies
;
1191 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1195 /* WIDL generated headers may be used */
1196 vector
<FileLocation
> rpcDependencies
;
1197 GetRpcHeaderDependencies ( rpcDependencies
);
1198 if ( rpcDependencies
.size () > 0 )
1199 dependencies
+= " " + backend
->v2s ( rpcDependencies
, 5 );
1201 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
);
1205 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1207 const Property
* property
= module
.project
.LookupProperty(name
);
1210 return property
->value
;
1212 return string ( "" );
1215 /* caller needs to delete the returned object */
1217 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1219 string newname
= GetBasename ( base
->name
) + "_s.h";
1220 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1223 /* caller needs to delete the returned object */
1225 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1227 string newname
= GetBasename ( base
->name
) + "_c.h";
1228 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1231 /* caller needs to delete the returned object */
1233 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1235 string newname
= GetBasename ( base
->name
) + "_p.h";
1236 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1239 /* caller needs to delete the returned object */
1241 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1243 string newname
= GetBasename ( base
->name
) + ".h";
1244 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1247 /* caller needs to delete the returned object */
1249 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1251 string newname
= GetBasename ( base
->name
) + ".h";
1252 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1256 MingwModuleHandler::GenerateCommands (
1257 const CompilationUnit
& compilationUnit
,
1258 const string
& extraDependencies
)
1260 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1261 string extension
= GetExtension ( sourceFile
);
1262 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1271 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1272 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1273 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1274 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1275 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1276 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1277 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1278 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1279 { HostDontCare
, IdlInterface
, ".idl", &widlInterfaceRule
},
1280 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1281 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1282 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1283 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1284 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1285 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1286 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1287 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1288 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1289 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1290 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1293 Rule
*customRule
= NULL
;
1295 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1297 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1299 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1301 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1303 customRule
= rules
[i
].rule
;
1307 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1309 GenerateGccCommand ( &sourceFile
,
1311 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1313 else if ( customRule
)
1314 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1317 throw InvalidOperationException ( __FILE__
,
1319 "Unsupported filename extension '%s' in file '%s'",
1321 backend
->GetFullName ( sourceFile
).c_str () );
1326 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1328 fprintf ( fMakefile
, "# BUILD MAP CODE\n" );
1330 fprintf ( fMakefile
,
1331 "ifeq ($(ROS_BUILDMAP),full)\n" );
1333 FileLocation
mapFilename ( OutputDirectory
,
1334 module
.output
->relative_path
,
1335 GetBasename ( module
.output
->name
) + ".map" );
1336 CLEAN_FILE ( mapFilename
);
1338 fprintf ( fMakefile
,
1339 "\t$(ECHO_OBJDUMP)\n" );
1340 fprintf ( fMakefile
,
1341 "\t$(Q)${objdump} -d -S %s > %s\n",
1342 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1343 backend
->GetFullName ( mapFilename
).c_str () );
1345 fprintf ( fMakefile
,
1347 fprintf ( fMakefile
,
1348 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1350 fprintf ( fMakefile
,
1352 fprintf ( fMakefile
,
1353 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1354 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1355 backend
->GetFullName ( mapFilename
).c_str () );
1357 fprintf ( fMakefile
,
1360 fprintf ( fMakefile
,
1365 MergeStringVector ( const Backend
* backend
,
1366 const vector
<FileLocation
>& input
,
1367 vector
<string
>& output
)
1371 int wrap_count
= -1;
1372 for ( size_t i
= 0; i
< input
.size (); i
++ )
1374 if ( wrap_count
++ == wrap_at
)
1376 output
.push_back ( s
);
1380 else if ( s
.size () > 0)
1382 s
+= backend
->GetFullName ( input
[i
] );
1384 if ( s
.length () > 0 )
1385 output
.push_back ( s
);
1389 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1390 vector
<FileLocation
>& objectFiles
) const
1392 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1394 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1395 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1396 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1397 objectFiles
.push_back ( *object_file
);
1403 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1405 if ( backend
->configuration
.CleanAsYouGo
)
1407 vector
<FileLocation
> objectFiles
;
1408 GetObjectsVector ( module
.non_if_data
,
1410 vector
<string
> lines
;
1411 MergeStringVector ( backend
,
1414 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1416 fprintf ( fMakefile
,
1417 "\t-@${rm} %s 2>$(NUL)\n",
1418 lines
[i
].c_str () );
1424 MingwModuleHandler::GenerateLinkerCommand () const
1426 string definitionFilename
;
1428 const FileLocation
*DefinitionFilename
= GetDefinitionFilename ();
1430 if ( DefinitionFilename
) {
1431 definitionFilename
= backend
->GetFullName (*DefinitionFilename
);
1432 delete DefinitionFilename
;
1435 string linkerScriptArgument
;
1436 if ( module
.linkerScript
!= NULL
) {
1437 if ( module
.project
.configuration
.Linker
== GnuLd
)
1438 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1441 "Linker doesn't support linker scripts: linker script %s ignored for module %s\n",
1442 backend
->GetFullName ( *module
.linkerScript
->file
).c_str (),
1443 module
.name
.c_str() );
1446 string extraLibraries
;
1447 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
) {
1448 if ( module
.cplusplus
) {
1449 switch ( module
.type
)
1456 extraLibraries
= "$$(PROJECT_CXXLIBS)";
1460 extraLibraries
= "$$(PROJECT_CCLIBS)";
1464 extraLibraries
= "$$(PROJECT_CCLIBS)";
1467 delete PassThruCacheDirectory ( new FileLocation ( module
.output
->directory
, module
.output
->relative_path
, "" ) );
1468 delete PassThruCacheDirectory ( new FileLocation ( IntermediateDirectory
, module
.output
->relative_path
, "" ) );
1470 fprintf ( fMakefile
,
1471 "$(eval $(call RBUILD_LINK_RULE,%s,%s,%s,%s,%s,%s,%s))\n",
1472 module
.name
.c_str(),
1473 definitionFilename
.c_str(),
1474 module
.xmlbuildFile
.c_str(),
1475 linkerScriptArgument
.c_str(),
1476 extraLibraries
.c_str(),
1477 module
.GetEntryPoint().c_str(),
1478 module
.baseaddress
.c_str() );
1482 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1485 string moduleDependencies
;
1487 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1488 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1490 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1491 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1492 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1493 if ( GetExtension ( *objectFilename
) == ".h" )
1494 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1495 else if ( GetExtension ( *objectFilename
) == ".rc" )
1496 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1497 delete objectFilename
;
1500 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1502 GenerateCommands ( *compilationUnits
[i
],
1503 moduleDependencies
);
1506 vector
<CompilationUnit
*> sourceCompilationUnits
;
1507 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1508 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1510 GenerateCommands ( *sourceCompilationUnits
[i
],
1511 moduleDependencies
);
1513 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1515 if ( module
.type
== RpcProxy
)
1517 widlDlldataRule
.Execute ( fMakefile
,
1520 GetDlldataFilename(),
1522 ssprintf ( "$(%s_SOURCES)", module
.name
.c_str ()) );
1527 MingwModuleHandler::GenerateObjectFileTargets ()
1529 if ( module
.pch
&& use_pch
)
1532 std::map
<string
, string
> vars
;
1534 /* WIDL generated headers may be used */
1535 string dependencies
;
1536 vector
<FileLocation
> rpcDependencies
;
1537 GetRpcHeaderDependencies ( rpcDependencies
);
1538 if ( rpcDependencies
.size () > 0 )
1539 dependencies
= " " + backend
->v2s ( rpcDependencies
, 5 );
1541 if ( module
.cplusplus
)
1542 pchCxxRule
.Execute ( fMakefile
, backend
, module
, module
.pch
->file
, clean_files
, dependencies
);
1544 pchRule
.Execute ( fMakefile
, backend
, module
, module
.pch
->file
, clean_files
, dependencies
);
1547 GenerateObjectFileTargets ( module
.non_if_data
);
1550 /* caller needs to delete the returned object */
1552 MingwModuleHandler::GenerateArchiveTarget ()
1554 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1556 if ( archiveFilename
== NULL
)
1559 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1561 fprintf ( fMakefile
, "# ARCHIVE TARGET\n" );
1563 if ( IsStaticLibrary ( module
) && definitionFilename
)
1565 arRule1
.Execute ( fMakefile
,
1570 backend
->GetFullName ( *definitionFilename
).c_str () );
1572 fprintf ( fMakefile
,
1573 "\t${dlltool} --def %s --kill-at --output-lib $@\n",
1574 backend
->GetFullName ( *definitionFilename
).c_str () );
1577 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1579 if ( definitionFilename
)
1580 delete definitionFilename
;
1582 if(module
.type
== HostStaticLibrary
)
1583 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1585 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1587 GenerateCleanObjectsAsYouGoCode ();
1589 fprintf ( fMakefile
, "\n" );
1591 return archiveFilename
;
1595 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1597 return ssprintf ( "$(%s_OBJS)",
1598 module
.name
.c_str () );
1602 MingwModuleHandler::GetLibsMacro () const
1604 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1608 MingwModuleHandler::GetLinkerMacro () const
1610 return ssprintf ( "$(%s_LDFLAGS)",
1611 module
.name
.c_str () );
1615 MingwModuleHandler::GetDebugFormat ()
1617 if (Environment::GetArch() == "amd64")
1625 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1627 if ( ReferenceObjects ( module
) )
1628 return GetObjectsMacro ( module
);
1631 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1632 string target
= backend
->GetFullName ( *target_file
).c_str ();
1639 MingwModuleHandler::GenerateSourceMacro ()
1641 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1643 if ( module
.type
== RpcProxy
|| module
.type
== Cabinet
)
1644 GenerateSourceMacros ( module
.non_if_data
);
1646 // future references to the macro will be to get its values
1647 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1651 MingwModuleHandler::GenerateObjectMacro ()
1653 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1655 GenerateObjectMacros ( module
.non_if_data
);
1657 // future references to the macro will be to get its values
1658 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1662 MingwModuleHandler::GenerateTargetMacro ()
1664 fprintf ( fMakefile
,
1666 GetTargetMacro ( module
, false ).c_str (),
1667 GetModuleTargets ( module
).c_str () );
1671 MingwModuleHandler::GetRpcHeaderDependencies (
1672 vector
<FileLocation
>& dependencies
) const
1674 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1676 Library
& library
= *module
.non_if_data
.libraries
[i
];
1677 if ( library
.importedModule
->type
== RpcServer
||
1678 library
.importedModule
->type
== RpcClient
||
1679 library
.importedModule
->type
== RpcProxy
||
1680 library
.importedModule
->type
== IdlHeader
)
1682 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1684 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1685 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1686 string extension
= GetExtension ( sourceFile
);
1687 if ( extension
== ".idl" || extension
== ".IDL" )
1689 string basename
= GetBasename ( sourceFile
.name
);
1690 if ( library
.importedModule
->type
== RpcServer
)
1692 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1693 dependencies
.push_back ( *header
);
1696 if ( library
.importedModule
->type
== RpcClient
)
1698 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1699 dependencies
.push_back ( *header
);
1702 if ( library
.importedModule
->type
== RpcProxy
)
1704 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1705 dependencies
.push_back ( *header
);
1708 if ( library
.importedModule
->type
== IdlHeader
)
1710 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1711 dependencies
.push_back ( *header
);
1721 MingwModuleHandler::GenerateOtherMacros ()
1723 set
<const Define
*> used_defs
;
1725 linkerflagsMacro
= ssprintf ("%s_LDFLAGS", module
.name
.c_str ());
1726 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1728 const FileLocation
* pchPath
= GetPrecompiledHeaderPath ();
1732 string pchPathStr
= backend
->GetFullName ( *pchPath
);
1735 fprintf ( fMakefile
,
1736 "%s_%sINCLUDES+= -I%s\n",
1737 module
.name
.c_str(),
1738 CompilerPrefixTable
[CompilerTypeCC
],
1739 pchPathStr
.c_str() );
1741 fprintf ( fMakefile
,
1742 "%s_%sINCLUDES+= -I%s\n",
1743 module
.name
.c_str(),
1744 CompilerPrefixTable
[CompilerTypeCXX
],
1745 pchPathStr
.c_str() );
1748 const char * toolPrefix
= "";
1750 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1751 toolPrefix
= "HOST_";
1753 // FIXME: this is very ugly and generates lots of useless entries
1754 for ( unsigned type
= CompilerTypeCC
; type
< CompilerTypesCount
; ++ type
)
1758 if ( module
.dynamicCRT
)
1759 flags
+= ssprintf ( " $(%s%sFLAG_CRTDLL)", toolPrefix
, CompilerPrefixTable
[type
] );
1761 // FIXME: this duplicates the flag for CPP and C/CXX
1762 if ( !module
.allowWarnings
)
1763 flags
+= ssprintf ( " $(%s%sFLAG_WERROR)", toolPrefix
, CompilerPrefixTable
[type
] );
1765 if ( module
.isUnicode
)
1766 flags
+= ssprintf ( " $(%s%sFLAG_UNICODE)", toolPrefix
, CompilerPrefixTable
[type
] );
1770 fprintf ( fMakefile
,
1772 module
.name
.c_str(),
1773 CompilerPrefixTable
[type
],
1778 GenerateParameters ( module
.name
.c_str(), "+=", module
.non_if_data
);
1783 &module
.linkerFlags
,
1786 fprintf ( fMakefile
, "\n\n" );
1790 MingwModuleHandler::GenerateRules ()
1794 fprintf ( fMakefile
, "# RULES\n" );
1795 string targetMacro
= GetTargetMacro ( module
);
1796 //CLEAN_FILE ( targetMacro );
1797 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
1799 // generate phony target for module name
1800 fprintf ( fMakefile
, ".PHONY: %s\n",
1801 module
.name
.c_str () );
1802 string dependencies
= GetTargetMacro ( module
);
1803 if ( module
.type
== Test
)
1804 dependencies
+= " $(regtests_run_TARGET)";
1805 fprintf ( fMakefile
, "%s: %s\n\n",
1806 module
.name
.c_str (),
1807 dependencies
.c_str () );
1808 if ( module
.type
== Test
)
1810 fprintf ( fMakefile
,
1812 targetMacro
.c_str ());
1815 if ( !ReferenceObjects ( module
) )
1817 const FileLocation
* ar_target
= GenerateArchiveTarget ();
1824 spec
= module
.IsSpecDefinitionFile();
1831 defRule
= &winebuildPRule
;
1833 defRule
= &winebuildRule
;
1835 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
1838 GenerateObjectFileTargets ();
1842 MingwModuleHandler::GetInvocationDependencies (
1843 const Module
& module
,
1844 string_list
& dependencies
)
1846 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1848 Invoke
& invoke
= *module
.invocations
[i
];
1849 if ( invoke
.invokeModule
== &module
)
1850 /* Protect against circular dependencies */
1852 invoke
.GetTargets ( dependencies
);
1857 MingwModuleHandler::GenerateInvocations () const
1859 if ( module
.invocations
.size () == 0 )
1862 fprintf ( fMakefile
, "# INVOCATIONS\n" );
1864 size_t iend
= module
.invocations
.size ();
1865 for ( size_t i
= 0; i
< iend
; i
++ )
1867 const Invoke
& invoke
= *module
.invocations
[i
];
1869 if ( invoke
.invokeModule
->type
!= BuildTool
)
1871 throw XMLInvalidBuildFileException (
1872 module
.node
.location
,
1873 "Only modules of type buildtool can be invoked." );
1876 string invokeTarget
= module
.GetInvocationTarget ( i
);
1877 string_list invoke_targets
;
1878 assert ( invoke_targets
.size() );
1879 invoke
.GetTargets ( invoke_targets
);
1880 fprintf ( fMakefile
,
1882 invokeTarget
.c_str () );
1883 fprintf ( fMakefile
,
1885 invokeTarget
.c_str () );
1886 size_t j
, jend
= invoke_targets
.size();
1887 for ( j
= 0; j
< jend
; j
++ )
1889 fprintf ( fMakefile
,
1891 invoke_targets
[i
].c_str () );
1893 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1894 for ( j
= 1; j
< jend
; j
++ )
1895 fprintf ( fMakefile
,
1897 invoke_targets
[i
].c_str () );
1898 fprintf ( fMakefile
,
1900 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
1901 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1902 fprintf ( fMakefile
,
1904 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
1905 invoke
.GetParameters ().c_str () );
1910 MingwModuleHandler::GetPreconditionDependenciesName () const
1912 return module
.name
+ "_precondition";
1916 MingwModuleHandler::GetDefaultDependencies (
1917 string_list
& dependencies
) const
1919 /* Avoid circular dependency */
1920 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1923 if (module
.name
!= "psdk" &&
1924 module
.name
!= "dxsdk")
1926 dependencies
.push_back ( "$(psdk_TARGET) $(psdk_HEADERS)" );
1927 dependencies
.push_back ( "$(dxsdk_TARGET) $(dxsdk_HEADERS)" );
1930 if (module
.name
!= "errcodes" &&
1931 module
.name
!= "bugcodes" &&
1932 module
.name
!= "ntstatus")
1934 dependencies
.push_back ( "$(errcodes_TARGET) $(ERRCODES_MCHEADERS)" );
1935 dependencies
.push_back ( "$(bugcodes_TARGET) $(BUGCODES_MCHEADERS)" );
1936 dependencies
.push_back ( "$(ntstatus_TARGET) $(NTSTATUS_MCHEADERS)" );
1939 ///* Check if any dependent library relies on the generated headers */
1940 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
1942 // const Module& m = *module.project.modules[i];
1943 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
1945 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
1946 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
1947 // string extension = GetExtension ( sourceFile );
1948 // if (extension == ".mc" || extension == ".MC" )
1950 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
1951 // dependencies.push_back ( dependency );
1958 MingwModuleHandler::GeneratePreconditionDependencies ()
1960 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
1961 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1962 string_list dependencies
;
1963 GetDefaultDependencies ( dependencies
);
1964 GetModuleDependencies ( dependencies
);
1966 GetInvocationDependencies ( module
, dependencies
);
1968 if ( dependencies
.size() )
1970 fprintf ( fMakefile
,
1972 preconditionDependenciesName
.c_str () );
1973 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1974 fprintf ( fMakefile
,
1976 dependencies
[i
].c_str () );
1977 fprintf ( fMakefile
, "\n\n" );
1980 fprintf ( fMakefile
, "\n" );
1983 /* caller needs to delete the returned object */
1985 MingwModuleHandler::GetDefinitionFilename () const
1987 if ( module
.importLibrary
== NULL
)
1990 if ( module
.IsSpecDefinitionFile () )
1992 return new FileLocation ( IntermediateDirectory
,
1993 module
.importLibrary
->source
->relative_path
,
1994 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
1998 return new FileLocation ( SourceDirectory
,
1999 module
.importLibrary
->source
->relative_path
,
2000 module
.importLibrary
->source
->name
);
2005 MingwModuleHandler::GetSpecObjectDependencies (
2006 vector
<FileLocation
>& dependencies
,
2007 const FileLocation
*file
) const
2009 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2010 file
->relative_path
,
2011 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2015 MingwModuleHandler::GetMcObjectDependencies (
2016 vector
<FileLocation
>& dependencies
,
2017 const FileLocation
*file
) const
2019 string basename
= GetBasename ( file
->name
);
2021 FileLocation
defDependency ( IntermediateDirectory
,
2024 dependencies
.push_back ( defDependency
);
2026 FileLocation
stubsDependency ( IntermediateDirectory
,
2027 file
->relative_path
,
2029 dependencies
.push_back ( stubsDependency
);
2033 MingwModuleHandler::GetWidlObjectDependencies (
2034 vector
<FileLocation
>& dependencies
,
2035 const FileLocation
*file
) const
2037 string basename
= GetBasename ( file
->name
);
2038 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2040 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2041 file
->relative_path
,
2042 basename
+ "_s.c" );
2043 dependencies
.push_back ( serverSourceDependency
);
2044 dependencies
.push_back ( *generatedHeaderFilename
);
2046 delete generatedHeaderFilename
;
2050 MingwModuleHandler::GetDefinitionDependencies (
2051 vector
<FileLocation
>& dependencies
) const
2053 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2054 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2056 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2057 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2058 string extension
= GetExtension ( sourceFile
);
2060 if (extension
== ".spec" || extension
== ".pspec")
2061 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2063 if (extension
== ".idl")
2065 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2066 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2071 enum DebugSupportType
2078 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2084 case DebugKernelMode
:
2085 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2089 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2096 module
.non_if_data
.libraries
.push_back(pLibrary
);
2100 MingwAddCRTLibrary( Module
&module
)
2102 const char * crtAttr
= module
.CRT
.c_str ();
2103 const char * crtLib
= NULL
;
2105 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2107 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2109 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2110 crtLib
= "libcntpr";
2111 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2116 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2118 if ( pLibrary
->importedModule
== NULL
)
2120 throw XMLInvalidBuildFileException (
2121 module
.node
.location
,
2122 "module '%s' trying to import non-existant C runtime module '%s'",
2123 module
.name
.c_str(),
2127 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2131 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2132 : MingwModuleHandler ( module_
)
2137 MingwBuildToolModuleHandler::Process ()
2139 GenerateBuildToolModuleTarget ();
2143 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2145 string
targetMacro ( GetTargetMacro (module
) );
2146 string objectsMacro
= GetObjectsMacro ( module
);
2147 string libsMacro
= GetLibsMacro ();
2151 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2154 if ( module
.cplusplus
)
2155 linker
= "${host_gpp}";
2157 linker
= "${host_gcc}";
2159 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2160 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2161 targetMacro
.c_str (),
2162 objectsMacro
.c_str (),
2164 backend
->GetFullPath ( *target_file
).c_str () );
2165 fprintf ( fMakefile
, "\t$(ECHO_HOSTLD)\n" );
2166 fprintf ( fMakefile
,
2167 "\t%s %s -o $@ %s %s\n\n",
2169 GetLinkerMacro ().c_str (),
2170 objectsMacro
.c_str (),
2171 libsMacro
.c_str () );
2177 MingwKernelModuleHandler::MingwKernelModuleHandler (
2178 const Module
& module_
)
2180 : MingwModuleHandler ( module_
)
2185 MingwKernelModuleHandler::Process ()
2187 GenerateKernelModuleTarget ();
2191 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2194 GenerateLinkerCommand ();
2198 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2199 const Module
& module_
)
2201 : MingwModuleHandler ( module_
)
2207 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2209 MingwAddCRTLibrary ( module
);
2210 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2214 MingwKernelModeDLLModuleHandler::Process ()
2216 GenerateKernelModeDLLModuleTarget ();
2220 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2223 GenerateLinkerCommand ();
2227 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2228 const Module
& module_
)
2230 : MingwModuleHandler ( module_
)
2235 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2237 MingwAddCRTLibrary ( module
);
2238 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2242 MingwNativeDLLModuleHandler::Process ()
2244 GenerateNativeDLLModuleTarget ();
2248 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2251 GenerateLinkerCommand ();
2255 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2256 const Module
& module_
)
2258 : MingwModuleHandler ( module_
)
2263 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2265 MingwAddCRTLibrary ( module
);
2266 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2270 MingwNativeCUIModuleHandler::Process ()
2272 GenerateNativeCUIModuleTarget ();
2276 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2279 GenerateLinkerCommand ();
2283 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2284 const Module
& module_
)
2286 : MingwModuleHandler ( module_
)
2290 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2291 const Module
& module_
)
2293 : MingwModuleHandler ( module_
)
2298 MingwAddImplicitLibraries( Module
&module
)
2302 if ( module
.type
!= Win32DLL
2303 && module
.type
!= Win32OCX
2304 && module
.type
!= Win32CUI
2305 && module
.type
!= Win32GUI
2306 && module
.type
!= Win32SCR
)
2311 if ( module
.isDefaultEntryPoint
)
2313 if ( module
.IsDLL () )
2315 //pLibrary = new Library ( module, "__mingw_dllmain" );
2316 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2320 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2321 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2325 pLibrary
= new Library ( module
, "mingw_common" );
2326 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2328 MingwAddCRTLibrary ( module
);
2329 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2333 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2335 MingwAddImplicitLibraries ( module
);
2339 MingwWin32DLLModuleHandler::Process ()
2341 GenerateWin32DLLModuleTarget ();
2345 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2348 GenerateLinkerCommand ();
2353 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2355 MingwAddImplicitLibraries ( module
);
2359 MingwWin32OCXModuleHandler::Process ()
2361 GenerateWin32OCXModuleTarget ();
2365 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2368 GenerateLinkerCommand ();
2372 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2373 const Module
& module_
)
2375 : MingwModuleHandler ( module_
)
2380 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2382 MingwAddImplicitLibraries ( module
);
2386 MingwWin32CUIModuleHandler::Process ()
2388 GenerateWin32CUIModuleTarget ();
2392 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2395 GenerateLinkerCommand ();
2399 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2400 const Module
& module_
)
2402 : MingwModuleHandler ( module_
)
2407 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2409 MingwAddImplicitLibraries ( module
);
2413 MingwWin32GUIModuleHandler::Process ()
2415 GenerateWin32GUIModuleTarget ();
2419 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2422 GenerateLinkerCommand ();
2426 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2427 const Module
& module_
)
2429 : MingwModuleHandler ( module_
)
2434 MingwBootLoaderModuleHandler::Process ()
2436 GenerateBootLoaderModuleTarget ();
2440 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2442 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2443 string
targetMacro ( GetTargetMacro (module
) );
2444 string objectsMacro
= GetObjectsMacro ( module
);
2445 string libsMacro
= GetLibsMacro ();
2449 string objectsDir
= "${call RBUILD_intermediate_dir,$(" + module
.name
+ "_TARGET)}";
2450 string rspFile
= objectsDir
+ "$(SEP)" + module
.name
+ "_objs.rsp";
2452 /* Generate the rsp rule */
2453 fprintf(fMakefile
, "%s: $(%s_OBJS) %s | %s\n"
2455 "\t-@${rm} $@ 2>$(NUL)\n"
2456 "\t${cp} $(NUL) $@ >$(NUL)\n"
2457 "\t$(foreach obj,$(%s_LIBS),$(Q)echo $(QUOTE)$(subst \\,\\\\,$(obj))$(QUOTE)>>$@$(NL))\n\n",
2459 module
.name
.c_str(),
2460 module
.xmlbuildFile
.c_str(),
2462 module
.name
.c_str());
2464 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2465 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2466 targetMacro
.c_str (),
2469 backend
->GetFullPath ( *target_file
).c_str () );
2471 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2473 string linkerScriptArgument
;
2474 if ( module
.linkerScript
!= NULL
) {
2475 linkerScriptArgument
= ssprintf(" -T %s", backend
->GetFullName(*module
.linkerScript
->file
).c_str());
2478 /* Link the stripped booloader */
2480 "\t${ld} --strip-all --subsystem native --entry=%s --image-base=%s @%s $(PROJECT_CCLIBS) "
2481 "$(BUILTIN_LDFLAGS) $(PROJECT_LDFLAGS) $(LDFLAG_DRIVER) %s -o $@\n",
2482 module
.GetEntryPoint().c_str(),
2483 module
.baseaddress
.c_str(),
2485 linkerScriptArgument
.c_str() );
2487 /* Link an unstripped version */
2489 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n"
2490 "\t${ld} --subsystem native --entry=%s --image-base=%s @%s $(PROJECT_CCLIBS) "
2491 "$(BUILTIN_LDFLAGS) $(PROJECT_LDFLAGS) $(LDFLAG_DRIVER) %s -o %s$(SEP)%s.nostrip.sys\n"
2493 module
.GetEntryPoint().c_str(),
2494 module
.baseaddress
.c_str(),
2496 linkerScriptArgument
.c_str(),
2497 backend
->GetFullPath(*target_file
).c_str(),
2498 module
.name
.c_str());
2502 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2503 const Module
& module_
)
2504 : MingwModuleHandler ( module_
)
2509 MingwBootProgramModuleHandler::Process ()
2511 GenerateBootProgramModuleTarget ();
2515 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2517 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
2519 string
targetName ( module
.output
->name
);
2520 string
targetMacro ( GetTargetMacro (module
) );
2521 string workingDirectory
= GetWorkingDirectory ();
2522 FileLocation
junk_tmp ( TemporaryDirectory
,
2524 module
.name
+ ".junk.tmp" );
2525 FileLocation
junk_elf ( TemporaryDirectory
,
2527 module
.name
+ ".junk.elf" );
2528 FileLocation
junk_cpy ( TemporaryDirectory
,
2530 module
.name
+ ".junk.elf" );
2531 CLEAN_FILE ( junk_tmp
);
2532 CLEAN_FILE ( junk_elf
);
2533 CLEAN_FILE ( junk_cpy
);
2534 string objectsMacro
= GetObjectsMacro ( module
);
2535 string libsMacro
= GetLibsMacro ();
2536 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
2540 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2541 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
2542 targetMacro
.c_str (),
2543 objectsMacro
.c_str (),
2545 payload
->name
.c_str (),
2546 backend
->GetFullPath ( *target_file
).c_str () );
2548 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
2550 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
2551 module
.buildtype
.c_str (),
2552 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
2553 backend
->GetFullName ( junk_cpy
).c_str () );
2555 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
2556 module
.buildtype
.c_str (),
2557 backend
->GetFullName ( junk_cpy
).c_str (),
2558 backend
->GetFullName ( junk_tmp
).c_str () );
2560 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
2561 module
.buildtype
.c_str (),
2563 backend
->GetFullName ( junk_tmp
).c_str (),
2564 backend
->GetFullName ( junk_elf
).c_str () );
2566 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
2567 module
.buildtype
.c_str (),
2568 backend
->GetFullName ( junk_elf
).c_str (),
2569 backend
->GetFullName ( *module
.output
) .c_str () );
2571 fprintf ( fMakefile
,
2572 "\t-@${rm} %s %s %s 2>$(NUL)\n",
2573 backend
->GetFullName ( junk_tmp
).c_str (),
2574 backend
->GetFullName ( junk_elf
).c_str (),
2575 backend
->GetFullName ( junk_cpy
).c_str () );
2581 MingwIsoModuleHandler::MingwIsoModuleHandler (
2582 const Module
& module_
)
2584 : MingwModuleHandler ( module_
)
2589 MingwIsoModuleHandler::Process ()
2591 GenerateIsoModuleTarget ();
2595 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2596 const string
& bootcdDirectory
,
2597 vector
<FileLocation
>& destinations
)
2599 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2601 const Module
& m
= *p
->second
;
2604 if ( m
.bootstrap
!= NULL
)
2606 FileLocation
targetFile ( OutputDirectory
,
2607 m
.bootstrap
->base
.length () > 0
2608 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
2610 m
.bootstrap
->nameoncd
);
2611 OutputCopyCommandSingle ( *m
.output
, targetFile
);
2612 destinations
.push_back ( targetFile
);
2618 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2619 const string
& bootcdDirectory
,
2620 std::vector
<FileLocation
>& destinations
)
2622 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2624 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2625 FileLocation
targetFile ( OutputDirectory
,
2626 cdfile
.target
->relative_path
.length () > 0
2627 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
2629 cdfile
.target
->name
);
2630 OutputCopyCommandSingle ( *cdfile
.source
, targetFile
);
2631 destinations
.push_back ( targetFile
);
2633 for ( size_t i
= 0; i
< module
.cdfiles
.size (); i
++ )
2635 const CDFile
& cdfile
= *module
.cdfiles
[i
];
2636 FileLocation
targetFile ( OutputDirectory
,
2637 cdfile
.target
->relative_path
.length () > 0
2638 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
2640 cdfile
.target
->name
);
2641 OutputCopyCommandSingle ( *cdfile
.source
, targetFile
);
2642 destinations
.push_back ( targetFile
);
2647 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
2648 const string
& bootcdDirectory
)
2650 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2652 const Module
& m
= *p
->second
;
2655 if ( m
.bootstrap
!= NULL
)
2657 FileLocation
targetDirectory ( OutputDirectory
,
2658 m
.bootstrap
->base
.length () > 0
2659 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
2662 out
.push_back ( targetDirectory
);
2668 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
2669 const string
& bootcdDirectory
)
2671 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2673 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2674 FileLocation
targetDirectory ( OutputDirectory
,
2675 cdfile
.target
->relative_path
.length () > 0
2676 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
2679 out
.push_back( targetDirectory
);
2684 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
2685 const string
& bootcdDirectory
)
2687 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
2688 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
2692 MingwIsoModuleHandler::GetBootstrapCdFiles (
2693 vector
<FileLocation
>& out
) const
2695 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2697 const Module
& m
= *p
->second
;
2700 if ( m
.bootstrap
!= NULL
)
2702 out
.push_back ( *m
.output
);
2708 MingwIsoModuleHandler::GetNonModuleCdFiles (
2709 vector
<FileLocation
>& out
) const
2711 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2713 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2714 out
.push_back ( *cdfile
.source
);
2719 MingwIsoModuleHandler::GetCdFiles (
2720 vector
<FileLocation
>& out
) const
2722 GetBootstrapCdFiles ( out
);
2723 GetNonModuleCdFiles ( out
);
2727 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2729 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
2730 string bootcdDirectory
= module
.name
;
2731 FileLocation
bootcd ( OutputDirectory
,
2734 FileLocation
bootcdReactos ( OutputDirectory
,
2735 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
2739 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
2743 throw InvalidOperationException ( module
.node
.location
.c_str(),
2745 "Invalid bootsector. module '%s' requires <bootsector>",
2746 module
.name
.c_str ());
2749 const FileLocation
*isoboot
= bootModule
->output
;
2751 // prepare reactos.dff and reactos.inf
2752 FileLocation
reactosDff ( SourceDirectory
,
2753 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
2755 FileLocation
reactosInf ( bootcdReactos
.directory
,
2756 bootcdReactos
.relative_path
,
2760 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
2761 Iso/LiveIso outputs are generated in code base root
2763 string IsoName
= module
.output
->name
;
2765 fprintf ( fMakefile
, ".PHONY: %s_CABINET\n\n",
2766 module
.name
.c_str () );
2767 fprintf ( fMakefile
, "%s_CABINET: all $(cabman_TARGET) %s | %s\n",
2768 module
.name
.c_str (),
2769 backend
->GetFullName ( reactosDff
).c_str (),
2770 backend
->GetFullPath ( bootcdReactos
).c_str () );
2771 fprintf ( fMakefile
,
2772 "\t$(Q)$(cabman_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2773 backend
->GetFullName ( reactosDff
).c_str (),
2774 backend
->GetFullPath ( bootcdReactos
).c_str () );
2775 fprintf ( fMakefile
,
2776 "\t$(Q)$(cabman_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2777 backend
->GetFullName ( reactosDff
).c_str (),
2778 backend
->GetFullName ( reactosInf
).c_str (),
2779 backend
->GetFullPath ( bootcdReactos
).c_str ());
2780 fprintf ( fMakefile
,
2781 "\t-@${rm} %s 2>$(NUL)\n\n",
2782 backend
->GetFullName ( reactosInf
).c_str () );
2784 std::vector
<FileLocation
> sourceFiles
;
2785 OutputBootstrapfileCopyCommands ( bootcdDirectory
, sourceFiles
);
2786 OutputCdfileCopyCommands ( bootcdDirectory
, sourceFiles
);
2789 "\n%s_OBJS := %s\n\n",
2790 module
.name
.c_str (),
2791 backend
->v2s ( sourceFiles
, 5, true ).c_str () );
2793 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2794 module
.name
.c_str ());
2795 fprintf ( fMakefile
,
2796 "%s: $(%s_OBJS) %s_CABINET %s $(cdmake_TARGET) | %s\n",
2797 module
.name
.c_str (),
2798 module
.name
.c_str (),
2799 module
.name
.c_str (),
2800 backend
->GetFullName ( *isoboot
).c_str (),
2801 backend
->GetFullPath ( FileLocation ( OutputDirectory
,
2805 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2806 fprintf ( fMakefile
,
2807 "\t$(Q)$(cdmake_TARGET) -v -j -m -b %s %s REACTOS %s\n",
2808 backend
->GetFullName ( *isoboot
).c_str (),
2809 backend
->GetFullPath ( bootcd
).c_str (),
2811 fprintf ( fMakefile
,
2816 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2817 const Module
& module_
)
2819 : MingwModuleHandler ( module_
)
2824 MingwLiveIsoModuleHandler::Process ()
2826 GenerateLiveIsoModuleTarget ();
2830 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2832 FileLocation
dir ( OutputDirectory
,
2835 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
2839 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2840 string
& reactosDirectory
,
2841 std::vector
<FileLocation
>& destinations
)
2843 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2845 const Module
& m
= *p
->second
;
2850 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
2851 FileLocation
destination ( OutputDirectory
,
2852 m
.install
->relative_path
.length () > 0
2853 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
2854 : livecdDirectory
+ sSep
+ reactosDirectory
,
2856 OutputCopyCommandSingle ( *aliasedModule
.output
,
2858 destinations
.push_back ( destination
);
2864 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2865 string
& reactosDirectory
,
2866 std::vector
<FileLocation
>& destinations
)
2868 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2870 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2871 FileLocation
target ( OutputDirectory
,
2872 installfile
.target
->relative_path
.length () > 0
2873 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
2874 : livecdDirectory
+ sSep
+ reactosDirectory
,
2875 installfile
.target
->name
);
2876 OutputCopyCommandSingle ( *installfile
.source
, target
);
2877 destinations
.push_back ( target
);
2882 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
,
2883 vector
<FileLocation
>& destinations
)
2885 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
2886 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
2887 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
2888 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
2889 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
2890 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
2892 FileLocation
livecdIni ( SourceDirectory
,
2893 "boot" + sSep
+ "bootdata",
2895 FileLocation
destination ( OutputDirectory
,
2898 OutputCopyCommandSingle ( livecdIni
,
2900 destinations
.push_back ( destination
);
2904 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
,
2905 std::vector
<FileLocation
>& destinations
)
2907 FileLocation
freeldr ( OutputDirectory
,
2908 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
2910 FileLocation
destination ( OutputDirectory
,
2911 livecdDirectory
+ sSep
+ "loader",
2913 OutputCopyCommandSingle ( freeldr
,
2915 destinations
.push_back ( destination
);
2919 MingwLiveIsoModuleHandler::OutputMakeLinkCommand ( const string name
,
2920 const string application
,
2922 vector
<FileLocation
>& destinations
)
2924 FileLocation
location ( OutputDirectory
, path
, name
+ ".lnk" );
2925 fprintf ( fMakefile
,
2926 "%s : $(mkshelllink_TARGET)\n",
2927 backend
->GetFullNamePrefixSpaces ( *PassThruCacheDirectory ( &location
) ).c_str () );
2928 fprintf ( fMakefile
,
2929 "\t$(Q)$(mkshelllink_TARGET) -o \"%s\" -g {450D8FBA-AD25-11D0-98A8-0800361B1103} -c %s -i %s -m livecd_start.cmd\n",
2930 backend
->GetFullName ( location
).c_str (),
2931 application
.c_str (),
2932 application
.c_str () );
2933 destinations
.push_back ( location
);
2937 MingwLiveIsoModuleHandler::OutputShortcutCommands ( string
& livecdDirectory
,
2938 vector
<FileLocation
>& destinations
)
2940 string allUsersDir
= livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users";
2941 string defaultUserDir
= livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User";
2942 FileLocation
helperSource ( SourceDirectory
, "boot" + sSep
+ "bootdata", "livecd_start.cmd" );
2943 FileLocation
helperDest ( OutputDirectory
, defaultUserDir
+ sSep
+ "My Documents", "livecd_start.cmd" );
2944 OutputCopyCommandSingle ( helperSource
, helperDest
);
2945 destinations
.push_back ( helperDest
);
2947 string desktopDir
= allUsersDir
+ sSep
+ "Desktop";
2948 OutputMakeLinkCommand ( "Command Prompt", "cmd.exe", desktopDir
, destinations
);
2950 string startMenuDir
= allUsersDir
+ sSep
+ "Start Menu";
2951 OutputMakeLinkCommand ( "ReactOS Explorer", "explorer.exe", startMenuDir
+ sSep
+ "Programs", destinations
);
2953 string adminToolsDir
= startMenuDir
+ sSep
+ "Programs" + sSep
+ "Administrative Tools";
2954 OutputMakeLinkCommand ( "Device Manager", "devmgmt.exe", adminToolsDir
, destinations
);
2955 OutputMakeLinkCommand ( "Event Viewer", "eventvwr.exe", adminToolsDir
, destinations
);
2956 OutputMakeLinkCommand ( "Service Manager", "servman.exe", adminToolsDir
, destinations
);
2957 OutputMakeLinkCommand ( "System Configuration", "msconfig.exe", adminToolsDir
, destinations
);
2959 string accessibilityDir
= startMenuDir
+ sSep
+ "Programs" + sSep
+ "Accessibility";
2960 OutputMakeLinkCommand ( "Magnify", "magnify.exe", accessibilityDir
, destinations
);
2962 string accessoriesDir
= startMenuDir
+ sSep
+ "Programs" + sSep
+ "Accessories";
2963 OutputMakeLinkCommand ( "Calculator", "calc.exe", accessoriesDir
, destinations
);
2964 OutputMakeLinkCommand ( "Command Prompt", "cmd.exe", accessoriesDir
, destinations
);
2965 OutputMakeLinkCommand ( "Paint", "mspaint.exe", accessoriesDir
, destinations
);
2966 OutputMakeLinkCommand ( "Notepad", "notepad.exe", accessoriesDir
, destinations
);
2967 OutputMakeLinkCommand ( "Remote desktop", "mstsc.exe", accessoriesDir
, destinations
);
2968 OutputMakeLinkCommand ( "WordPad", "wordpad.exe", accessoriesDir
, destinations
);
2970 string entertainmentDir
= startMenuDir
+ sSep
+ "Programs" + sSep
+ "Entertainment";
2971 OutputMakeLinkCommand ( "Audiorecorder", "sndrec32.exe", entertainmentDir
, destinations
);
2972 OutputMakeLinkCommand ( "Multimedia Player", "mplay32.exe", entertainmentDir
, destinations
);
2973 OutputMakeLinkCommand ( "Volume Control", "sndvol32.exe", entertainmentDir
, destinations
);
2975 string gamesDir
= startMenuDir
+ sSep
+ "Programs" + sSep
+ "Games";
2976 OutputMakeLinkCommand ( "Solitaire", "sol.exe", gamesDir
, destinations
);
2977 OutputMakeLinkCommand ( "Spider Solitaire", "spider.exe", gamesDir
, destinations
);
2978 OutputMakeLinkCommand ( "WineMine", "winmine.exe", gamesDir
, destinations
);
2980 string sysToolsDir
= startMenuDir
+ sSep
+ "Programs" + sSep
+ "System Tools";
2981 OutputMakeLinkCommand ( "Character Map", "charmap.exe", sysToolsDir
, destinations
);
2982 OutputMakeLinkCommand ( "Keyboard Layout Switcher", "kbswitch.exe", sysToolsDir
, destinations
);
2983 OutputMakeLinkCommand ( "ReactX Diagnostic", "dxdiag.exe", sysToolsDir
, destinations
);
2984 OutputMakeLinkCommand ( "Regedit", "regedit.exe", sysToolsDir
, destinations
);
2988 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2990 string registrySourceFiles
= backend
->GetRegistrySourceFiles ();
2991 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
2992 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
2993 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
2995 fprintf ( fMakefile
,
2996 "\t$(ECHO_MKHIVE)\n" );
2997 fprintf ( fMakefile
,
2998 "\t$(Q)$(mkhive_TARGET) %s %s boot%cbootdata%clivecd.inf\n",
2999 backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
3000 registrySourceFiles
.c_str(),
3005 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
3007 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
3008 string livecdDirectory
= module
.name
;
3009 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
3014 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
3018 throw InvalidOperationException ( module
.node
.location
.c_str(),
3020 "Invalid bootsector. module '%s' requires <bootsector>",
3021 module
.name
.c_str ());
3024 const FileLocation
*isoboot
= bootModule
->output
;
3027 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
3028 Iso/LiveIso outputs are generated in code base root
3030 IsoName
= module
.output
->name
;
3032 string reactosDirectory
= "reactos";
3033 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
3034 FileLocation
livecdReactos ( OutputDirectory
,
3035 livecdReactosNoFixup
,
3037 CLEAN_FILE ( livecdReactos
);
3039 std::vector
<FileLocation
> sourceFiles
;
3040 OutputModuleCopyCommands ( livecdDirectory
,
3043 OutputNonModuleCopyCommands ( livecdDirectory
,
3046 OutputProfilesDirectoryCommands ( livecdDirectory
, sourceFiles
);
3047 OutputLoaderCommands ( livecdDirectory
, sourceFiles
);
3048 OutputShortcutCommands ( livecdDirectory
, sourceFiles
);
3051 "\n%s_OBJS := %s\n\n",
3052 module
.name
.c_str (),
3053 backend
->v2s ( sourceFiles
, 5, true ).c_str () );
3055 fprintf ( fMakefile
, ".PHONY: %s\n\n",
3056 module
.name
.c_str ());
3057 fprintf ( fMakefile
,
3058 "%s : $(%s_OBJS) %s %s $(mkhive_TARGET) $(cdmake_TARGET)\n",
3059 module
.name
.c_str (),
3060 module
.name
.c_str (),
3061 backend
->GetFullName ( *isoboot
) .c_str (),
3062 backend
->GetFullPath ( FileLocation ( OutputDirectory
,
3065 OutputRegistryCommands ( livecdDirectory
);
3066 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3067 fprintf ( fMakefile
,
3068 "\t$(Q)$(cdmake_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3069 backend
->GetFullName( *isoboot
).c_str (),
3070 backend
->GetFullPath ( livecd
).c_str (),
3072 fprintf ( fMakefile
,
3077 MingwTestModuleHandler::MingwTestModuleHandler (
3078 const Module
& module_
)
3080 : MingwModuleHandler ( module_
)
3085 MingwTestModuleHandler::Process ()
3087 GenerateTestModuleTarget ();
3090 /* caller needs to delete the returned object */
3092 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3094 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3095 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3096 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3100 MingwTestModuleHandler::GenerateTestModuleTarget ()
3103 GenerateLinkerCommand ();
3107 MingwAliasModuleHandler::MingwAliasModuleHandler (
3108 const Module
& module_
)
3110 : MingwModuleHandler ( module_
)
3115 MingwAliasModuleHandler::Process ()
3120 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3121 const Module
& module_
)
3123 : MingwModuleHandler ( module_
)
3128 MingwCabinetModuleHandler::Process ()
3130 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3131 string
targetMacro ( GetTargetMacro (module
) );
3135 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3136 fprintf ( fMakefile
, "%s: $(cabman_TARGET) | %s\n",
3137 targetMacro
.c_str (),
3138 backend
->GetFullPath ( *target_file
).c_str () );
3140 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3141 fprintf ( fMakefile
,
3142 "\t$(Q)$(cabman_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3143 targetMacro
.c_str (),
3144 module
.name
.c_str());
3147 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3148 const Module
& module_
)
3150 : MingwModuleHandler ( module_
)
3155 MingwElfExecutableModuleHandler::Process ()
3157 string
targetName ( module
.output
->name
);
3158 string
targetMacro ( GetTargetMacro (module
) );
3159 string workingDirectory
= GetWorkingDirectory ();
3160 string objectsMacro
= GetObjectsMacro ( module
);
3161 string libsMacro
= GetLibsMacro ();
3162 string debugFormat
= GetDebugFormat ();
3164 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3167 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3168 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3169 targetMacro
.c_str (),
3170 objectsMacro
.c_str (),
3172 backend
->GetFullPath ( *target_file
).c_str () );
3174 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3176 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g%s -o %s\n",
3177 module
.buildtype
.c_str(),
3178 objectsMacro
.c_str(),
3180 debugFormat
.c_str(),
3181 targetMacro
.c_str () );
3184 fprintf ( fMakefile
, "#/ELF EXECUTABLE TARGET\n" );