2 * Copyright (C) 2005 Casper S. Hornstrup
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #include "../../pch.h"
23 #include "modulehandler.h"
26 #define MKDIR(s) mkdir(s)
28 #define MKDIR(s) mkdir(s, 0755)
36 typedef set
<string
> set_string
;
40 v2s ( const string_list
& v
, int wrap_at
)
46 for ( size_t i
= 0; i
< v
.size(); i
++ )
50 if ( wrap_at
> 0 && wrap_count
++ == wrap_at
)
60 Directory::Directory ( const string
& name_
)
66 Directory::Add ( const char* subdir
)
69 string s1
= string ( subdir
);
70 if ( ( i
= s1
.find ( '$' ) ) != string::npos
)
72 throw InvalidOperationException ( __FILE__
,
74 "No environment variables can be used here. Path was %s",
78 const char* p
= strpbrk ( subdir
, "/\\" );
80 p
= subdir
+ strlen(subdir
);
81 string
s ( subdir
, p
-subdir
);
82 if ( subdirs
.find(s
) == subdirs
.end() )
83 subdirs
[s
] = new Directory(s
);
85 subdirs
[s
]->Add ( p
);
89 Directory::mkdir_p ( const char* path
)
92 directory
= opendir ( path
);
93 if ( directory
!= NULL
)
95 closedir ( directory
);
99 if ( MKDIR ( path
) != 0 )
100 throw AccessDeniedException ( string ( path
) );
105 Directory::CreateDirectory ( string path
)
109 if ( isalpha ( path
[0] ) && path
[1] == ':' && path
[2] == CSEP
)
111 nextIndex
= path
.find ( CSEP
, 3);
114 nextIndex
= path
.find ( CSEP
);
116 bool directoryWasCreated
= false;
117 while ( nextIndex
!= string::npos
)
119 nextIndex
= path
.find ( CSEP
, index
+ 1 );
120 directoryWasCreated
= mkdir_p ( path
.substr ( 0, nextIndex
).c_str () );
123 return directoryWasCreated
;
127 Directory::ReplaceVariable ( string name
,
131 size_t i
= path
.find ( name
);
132 if ( i
!= string::npos
)
133 return path
.replace ( i
, name
.length (), value
);
139 Directory::ResolveVariablesInPath ( char* buf
,
142 string s
= ReplaceVariable ( "$(INTERMEDIATE)", Environment::GetIntermediatePath (), path
);
143 s
= ReplaceVariable ( "$(OUTPUT)", Environment::GetOutputPath (), s
);
144 s
= ReplaceVariable ( "$(INSTALL)", Environment::GetInstallPath (), s
);
145 strcpy ( buf
, s
.c_str () );
149 Directory::GenerateTree ( const string
& parent
,
154 if ( parent
.size () > 0 )
158 path
= parent
+ SSEP
+ name
;
159 ResolveVariablesInPath ( buf
, path
);
160 if ( CreateDirectory ( buf
) && verbose
)
161 printf ( "Created %s\n", buf
);
166 for ( directory_map::iterator i
= subdirs
.begin ();
170 i
->second
->GenerateTree ( path
, verbose
);
175 Directory::EscapeSpaces ( string path
)
182 newpath
= newpath
+ "\\ ";
184 newpath
= newpath
+ *p
;
191 Directory::CreateRule ( FILE* f
,
192 const string
& parent
)
196 if ( parent
.size() > 0 )
198 string escapedParent
= EscapeSpaces ( parent
);
201 escapedParent
.c_str (),
203 EscapeSpaces ( name
).c_str (),
204 escapedParent
.c_str () );
207 "\t$(ECHO_MKDIR)\n" );
212 path
= parent
+ SSEP
+ name
;
217 for ( directory_map::iterator i
= subdirs
.begin();
221 i
->second
->CreateRule ( f
, path
);
226 static class MingwFactory
: public Backend::Factory
229 MingwFactory() : Factory ( "mingw" ) {}
230 Backend
* operator() ( Project
& project
,
231 Configuration
& configuration
)
233 return new MingwBackend ( project
,
239 MingwBackend::MingwBackend ( Project
& project
,
240 Configuration
& configuration
)
241 : Backend ( project
, configuration
),
242 intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ),
243 outputDirectory ( new Directory ( "$(OUTPUT)" ) ),
244 installDirectory ( new Directory ( "$(INSTALL)" ) )
249 MingwBackend::~MingwBackend()
251 delete intermediateDirectory
;
252 delete outputDirectory
;
253 delete installDirectory
;
257 MingwBackend::AddDirectoryTarget ( const string
& directory
,
258 Directory
* directoryTree
)
260 if ( directory
.length () > 0)
261 directoryTree
->Add ( directory
.c_str() );
262 return directoryTree
->name
;
266 MingwBackend::ProcessModules ()
268 printf ( "Processing modules..." );
270 vector
<MingwModuleHandler
*> v
;
272 for ( i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
274 Module
& module
= *ProjectNode
.modules
[i
];
275 if ( !module
.enabled
)
277 MingwModuleHandler
* h
= MingwModuleHandler::InstanciateHandler (
280 if ( module
.host
== HostDefault
)
282 module
.host
= h
->DefaultHost();
283 assert ( module
.host
!= HostDefault
);
288 size_t iend
= v
.size ();
290 for ( i
= 0; i
< iend
; i
++ )
291 v
[i
]->GenerateObjectMacro();
292 fprintf ( fMakefile
, "\n" );
293 for ( i
= 0; i
< iend
; i
++ )
294 v
[i
]->GenerateTargetMacro();
295 fprintf ( fMakefile
, "\n" );
297 GenerateAllTarget ( v
);
298 GenerateInitTarget ();
299 GenerateRegTestsRunTarget ();
301 for ( i
= 0; i
< iend
; i
++ )
302 v
[i
]->GenerateOtherMacros();
304 for ( i
= 0; i
< iend
; i
++ )
306 MingwModuleHandler
& h
= *v
[i
];
307 h
.GeneratePreconditionDependencies ();
309 h
.GenerateInvocations ();
310 h
.GenerateCleanTarget ();
311 h
.GenerateInstallTarget ();
312 h
.GenerateDependsTarget ();
320 MingwBackend::Process ()
322 if ( configuration
.CheckDependenciesForModuleOnly
)
323 CheckAutomaticDependenciesForModuleOnly ();
329 MingwBackend::CheckAutomaticDependenciesForModuleOnly ()
331 if ( configuration
.AutomaticDependencies
)
333 Module
* module
= ProjectNode
.LocateModule ( configuration
.CheckDependenciesForModuleOnlyModule
);
334 if ( module
== NULL
)
336 printf ( "Module '%s' does not exist\n",
337 configuration
.CheckDependenciesForModuleOnlyModule
.c_str () );
341 printf ( "Checking automatic dependencies for module '%s'...",
342 module
->name
.c_str () );
343 AutomaticDependency
automaticDependency ( ProjectNode
);
344 automaticDependency
.CheckAutomaticDependenciesForModule ( *module
,
345 configuration
.Verbose
);
351 MingwBackend::ProcessNormal ()
354 DetectNetwideAssembler ();
355 DetectPipeSupport ();
359 GenerateGlobalVariables ();
360 GenerateXmlBuildFilesMacro ();
362 GenerateInstallTarget ();
363 GenerateTestTarget ();
364 GenerateDirectoryTargets ();
365 GenerateDirectories ();
366 UnpackWineResources ();
367 GenerateTestSupportCode ();
368 GenerateProxyMakefiles ();
369 CheckAutomaticDependencies ();
374 MingwBackend::CreateMakefile ()
376 fMakefile
= fopen ( ProjectNode
.makefile
.c_str (), "w" );
378 throw AccessDeniedException ( ProjectNode
.makefile
);
379 MingwModuleHandler::SetBackend ( this );
380 MingwModuleHandler::SetMakefile ( fMakefile
);
381 MingwModuleHandler::SetUsePch ( use_pch
);
385 MingwBackend::CloseMakefile () const
388 fclose ( fMakefile
);
392 MingwBackend::GenerateHeader () const
394 fprintf ( fMakefile
, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
398 MingwBackend::GenerateIncludesAndDefines ( IfableData
& data
) const
400 string includeParameters
= MingwModuleHandler::GenerateGccIncludeParametersFromVector ( data
.includes
);
401 string defineParameters
= MingwModuleHandler::GenerateGccDefineParametersFromVector ( data
.defines
);
402 return includeParameters
+ " " + defineParameters
;
406 MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation
,
407 IfableData
& data
) const
412 assignmentOperation
);
416 GenerateIncludesAndDefines ( data
).c_str() );
418 fprintf ( fMakefile
, "\n" );
422 MingwBackend::GenerateGlobalCFlagsAndProperties (
423 const char* assignmentOperation
,
424 IfableData
& data
) const
428 for ( i
= 0; i
< data
.properties
.size(); i
++ )
430 Property
& prop
= *data
.properties
[i
];
431 fprintf ( fMakefile
, "%s := %s\n",
433 prop
.value
.c_str() );
436 if ( data
.includes
.size() || data
.defines
.size() )
438 GenerateProjectCFlagsMacro ( assignmentOperation
,
442 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
444 If
& rIf
= *data
.ifs
[i
];
445 if ( rIf
.data
.defines
.size()
446 || rIf
.data
.includes
.size()
447 || rIf
.data
.ifs
.size() )
451 "ifeq (\"$(%s)\",\"%s\")\n",
452 rIf
.property
.c_str(),
454 GenerateGlobalCFlagsAndProperties (
465 MingwBackend::GenerateProjectGccOptionsMacro ( const char* assignmentOperation
,
466 IfableData
& data
) const
472 "PROJECT_GCCOPTIONS %s",
473 assignmentOperation
);
475 for ( i
= 0; i
< data
.compilerFlags
.size(); i
++ )
480 data
.compilerFlags
[i
]->flag
.c_str() );
483 fprintf ( fMakefile
, "\n" );
487 MingwBackend::GenerateProjectGccOptions (
488 const char* assignmentOperation
,
489 IfableData
& data
) const
493 if ( data
.compilerFlags
.size() )
495 GenerateProjectGccOptionsMacro ( assignmentOperation
,
499 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
501 If
& rIf
= *data
.ifs
[i
];
502 if ( rIf
.data
.compilerFlags
.size()
503 || rIf
.data
.ifs
.size() )
507 "ifeq (\"$(%s)\",\"%s\")\n",
508 rIf
.property
.c_str(),
510 GenerateProjectGccOptions (
521 MingwBackend::GenerateProjectLFLAGS () const
524 for ( size_t i
= 0; i
< ProjectNode
.linkerFlags
.size (); i
++ )
526 LinkerFlag
& linkerFlag
= *ProjectNode
.linkerFlags
[i
];
527 if ( lflags
.length () > 0 )
529 lflags
+= linkerFlag
.flag
;
535 MingwBackend::GenerateGlobalVariables () const
539 compilerPrefix
.c_str () );
542 nasmCommand
.c_str () );
544 GenerateGlobalCFlagsAndProperties ( "=", ProjectNode
.non_if_data
);
545 GenerateProjectGccOptions ( "=", ProjectNode
.non_if_data
);
547 fprintf ( fMakefile
, "PROJECT_RCFLAGS := $(PROJECT_CFLAGS)\n" );
548 fprintf ( fMakefile
, "PROJECT_WIDLFLAGS := $(PROJECT_CFLAGS)\n" );
549 fprintf ( fMakefile
, "PROJECT_LFLAGS := %s\n",
550 GenerateProjectLFLAGS ().c_str () );
551 fprintf ( fMakefile
, "PROJECT_CFLAGS += -Wall\n" );
552 fprintf ( fMakefile
, "PROJECT_CFLAGS += $(PROJECT_GCCOPTIONS)\n" );
553 fprintf ( fMakefile
, "\n" );
557 MingwBackend::IncludeInAllTarget ( const Module
& module
) const
559 if ( MingwModuleHandler::ReferenceObjects ( module
) )
561 if ( module
.type
== BootSector
)
563 if ( module
.type
== Iso
)
565 if ( module
.type
== LiveIso
)
567 if ( module
.type
== Test
)
569 if ( module
.type
== Alias
)
575 MingwBackend::GenerateAllTarget ( const vector
<MingwModuleHandler
*>& handlers
) const
577 fprintf ( fMakefile
, "all:" );
579 size_t iend
= handlers
.size ();
580 for ( size_t i
= 0; i
< iend
; i
++ )
582 const Module
& module
= handlers
[i
]->module
;
583 if ( IncludeInAllTarget ( module
) )
585 if ( wrap_count
++ == 5 )
586 fprintf ( fMakefile
, " \\\n\t\t" ), wrap_count
= 0;
589 GetTargetMacro(module
).c_str () );
592 fprintf ( fMakefile
, "\n\t\n\n" );
596 MingwBackend::GetBuildToolDependencies () const
599 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
601 Module
& module
= *ProjectNode
.modules
[i
];
602 if ( !module
.enabled
)
604 if ( module
.type
== BuildTool
)
606 if ( dependencies
.length () > 0 )
608 dependencies
+= module
.GetDependencyPath ();
615 MingwBackend::GenerateInitTarget () const
619 GetBuildToolDependencies ().c_str () );
620 fprintf ( fMakefile
, "\n" );
624 MingwBackend::GenerateRegTestsRunTarget () const
627 "REGTESTS_RUN_TARGET = regtests.dll\n" );
629 "$(REGTESTS_RUN_TARGET): $(REGTESTS_TARGET)\n" );
631 "\t$(cp) $(REGTESTS_TARGET) $(REGTESTS_RUN_TARGET)\n" );
632 fprintf ( fMakefile
, "\n" );
636 MingwBackend::GenerateXmlBuildFilesMacro() const
639 "XMLBUILDFILES = %s \\\n",
640 ProjectNode
.GetProjectFilename ().c_str () );
641 string xmlbuildFilenames
;
642 int numberOfExistingFiles
= 0;
643 for ( size_t i
= 0; i
< ProjectNode
.xmlbuildfiles
.size (); i
++ )
645 XMLInclude
& xmlbuildfile
= *ProjectNode
.xmlbuildfiles
[i
];
646 if ( !xmlbuildfile
.fileExists
)
648 numberOfExistingFiles
++;
649 if ( xmlbuildFilenames
.length () > 0 )
650 xmlbuildFilenames
+= " ";
651 xmlbuildFilenames
+= NormalizeFilename ( xmlbuildfile
.topIncludeFilename
);
652 if ( numberOfExistingFiles
% 5 == 4 || i
== ProjectNode
.xmlbuildfiles
.size () - 1 )
656 xmlbuildFilenames
.c_str ());
657 if ( i
== ProjectNode
.xmlbuildfiles
.size () - 1 )
659 fprintf ( fMakefile
, "\n" );
666 xmlbuildFilenames
.resize ( 0 );
668 numberOfExistingFiles
++;
670 fprintf ( fMakefile
, "\n" );
674 MingwBackend::GetBin2ResExecutable ()
676 return NormalizeFilename ( Environment::GetOutputPath () + SSEP
+ "tools/bin2res/bin2res" + EXEPOSTFIX
);
680 MingwBackend::UnpackWineResources ()
682 printf ( "Unpacking WINE resources..." );
683 WineResource
wineResource ( ProjectNode
,
684 GetBin2ResExecutable () );
685 wineResource
.UnpackResources ( configuration
.Verbose
);
690 MingwBackend::GenerateTestSupportCode ()
692 printf ( "Generating test support code..." );
693 TestSupportCode
testSupportCode ( ProjectNode
);
694 testSupportCode
.GenerateTestSupportCode ( configuration
.Verbose
);
699 MingwBackend::GetProxyMakefileTree () const
701 if ( configuration
.GenerateProxyMakefilesInSourceTree
)
704 return Environment::GetOutputPath ();
708 MingwBackend::GenerateProxyMakefiles ()
710 printf ( "Generating proxy makefiles..." );
711 ProxyMakefile
proxyMakefile ( ProjectNode
);
712 proxyMakefile
.GenerateProxyMakefiles ( configuration
.Verbose
,
713 GetProxyMakefileTree () );
718 MingwBackend::CheckAutomaticDependencies ()
720 if ( configuration
.AutomaticDependencies
)
722 printf ( "Checking automatic dependencies..." );
723 AutomaticDependency
automaticDependency ( ProjectNode
);
724 automaticDependency
.CheckAutomaticDependencies ( configuration
.Verbose
);
730 MingwBackend::IncludeDirectoryTarget ( const string
& directory
) const
732 if ( directory
== "$(INTERMEDIATE)" SSEP
"tools")
739 MingwBackend::GenerateDirectories ()
741 printf ( "Creating directories..." );
742 intermediateDirectory
->GenerateTree ( "", configuration
.Verbose
);
743 outputDirectory
->GenerateTree ( "", configuration
.Verbose
);
744 if ( !configuration
.MakeHandlesInstallDirectories
)
745 installDirectory
->GenerateTree ( "", configuration
.Verbose
);
750 MingwBackend::TryToDetectThisCompiler ( const string
& compiler
)
752 string command
= ssprintf (
757 int exitcode
= system ( command
.c_str () );
758 return (exitcode
== 0);
762 MingwBackend::DetectCompiler ()
764 printf ( "Detecting compiler..." );
766 bool detectedCompiler
= false;
767 const string
& ROS_PREFIXValue
= Environment::GetVariable ( "ROS_PREFIX" );
768 if ( ROS_PREFIXValue
.length () > 0 )
770 compilerPrefix
= ROS_PREFIXValue
;
771 compilerCommand
= compilerPrefix
+ "-gcc";
772 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
775 if ( !detectedCompiler
)
778 compilerCommand
= "gcc";
779 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
782 if ( !detectedCompiler
)
784 compilerPrefix
= "mingw32";
785 compilerCommand
= compilerPrefix
+ "-gcc";
786 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
788 if ( detectedCompiler
)
789 printf ( "detected (%s)\n", compilerCommand
.c_str () );
791 printf ( "not detected\n" );
795 MingwBackend::TryToDetectThisNetwideAssembler ( const string
& assembler
)
797 string command
= ssprintf (
802 int exitcode
= system ( command
.c_str () );
803 return (exitcode
== 0);
807 MingwBackend::DetectNetwideAssembler ()
809 printf ( "Detecting netwide assembler..." );
811 nasmCommand
= "nasm";
812 bool detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
816 nasmCommand
= "nasmw";
817 detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
822 nasmCommand
= "yasm";
823 detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
826 printf ( "detected (%s)\n", nasmCommand
.c_str () );
828 printf ( "not detected\n" );
832 MingwBackend::DetectPipeSupport ()
834 printf ( "Detecting compiler -pipe support..." );
836 string pipe_detection
= "tools" SSEP
"rbuild" SSEP
"backend" SSEP
"mingw" SSEP
"pipe_detection.c";
837 string pipe_detectionObjectFilename
= ReplaceExtension ( pipe_detection
,
839 string command
= ssprintf (
840 "%s -pipe -c %s -o %s 1>%s 2>%s",
841 compilerCommand
.c_str (),
842 pipe_detection
.c_str (),
843 pipe_detectionObjectFilename
.c_str (),
846 int exitcode
= system ( command
.c_str () );
847 FILE* f
= fopen ( pipe_detectionObjectFilename
.c_str (), "rb" );
850 usePipe
= (exitcode
== 0);
852 unlink ( pipe_detectionObjectFilename
.c_str () );
858 printf ( "detected\n" );
860 printf ( "not detected\n" );
864 MingwBackend::DetectPCHSupport ()
866 printf ( "Detecting compiler pre-compiled header support..." );
868 string path
= "tools" SSEP
"rbuild" SSEP
"backend" SSEP
"mingw" SSEP
"pch_detection.h";
869 string cmd
= ssprintf (
870 "%s -c %s 1>%s 2>%s",
871 compilerCommand
.c_str (),
875 system ( cmd
.c_str () );
878 FILE* f
= fopen ( path
.c_str (), "rb" );
883 unlink ( path
.c_str () );
889 printf ( "detected\n" );
891 printf ( "not detected\n" );
895 MingwBackend::GetNonModuleInstallTargetFiles (
896 vector
<string
>& out
) const
898 for ( size_t i
= 0; i
< ProjectNode
.installfiles
.size (); i
++ )
900 const InstallFile
& installfile
= *ProjectNode
.installfiles
[i
];
901 string targetFilenameNoFixup
= installfile
.base
+ SSEP
+ installfile
.newname
;
902 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
903 NormalizeFilename ( targetFilenameNoFixup
),
905 out
.push_back ( targetFilename
);
910 MingwBackend::GetModuleInstallTargetFiles (
911 vector
<string
>& out
) const
913 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
915 const Module
& module
= *ProjectNode
.modules
[i
];
916 if ( !module
.enabled
)
918 if ( module
.installName
.length () > 0 )
920 string targetFilenameNoFixup
;
921 if ( module
.installBase
.length () > 0 )
922 targetFilenameNoFixup
= module
.installBase
+ SSEP
+ module
.installName
;
924 targetFilenameNoFixup
= module
.installName
;
925 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
926 NormalizeFilename ( targetFilenameNoFixup
),
928 out
.push_back ( targetFilename
);
934 MingwBackend::GetInstallTargetFiles (
935 vector
<string
>& out
) const
937 GetNonModuleInstallTargetFiles ( out
);
938 GetModuleInstallTargetFiles ( out
);
942 MingwBackend::OutputInstallTarget ( const string
& sourceFilename
,
943 const string
& targetFilename
,
944 const string
& targetDirectory
)
946 string fullTargetFilename
;
947 if ( targetDirectory
.length () > 0)
948 fullTargetFilename
= targetDirectory
+ SSEP
+ targetFilename
;
950 fullTargetFilename
= targetFilename
;
951 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
952 NormalizeFilename ( fullTargetFilename
),
954 string normalizedTargetDirectory
= MingwModuleHandler::PassThruCacheDirectory (
955 NormalizeFilename ( targetDirectory
),
959 normalizedTargetFilename
.c_str (),
960 sourceFilename
.c_str (),
961 normalizedTargetDirectory
.c_str () );
965 "\t${cp} %s %s 1>$(NUL)\n",
966 sourceFilename
.c_str (),
967 normalizedTargetFilename
.c_str () );
971 MingwBackend::OutputNonModuleInstallTargets ()
973 for ( size_t i
= 0; i
< ProjectNode
.installfiles
.size (); i
++ )
975 const InstallFile
& installfile
= *ProjectNode
.installfiles
[i
];
976 OutputInstallTarget ( installfile
.GetPath (),
983 MingwBackend::GetAliasedModuleOrModule ( const Module
& module
) const
985 if ( module
.aliasedModuleName
.size () > 0 )
987 const Module
* aliasedModule
= ProjectNode
.LocateModule ( module
.aliasedModuleName
);
988 assert ( aliasedModule
);
989 return *aliasedModule
;
996 MingwBackend::OutputModuleInstallTargets ()
998 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
1000 const Module
& module
= *ProjectNode
.modules
[i
];
1001 if ( !module
.enabled
)
1003 if ( module
.installName
.length () > 0 )
1005 const Module
& aliasedModule
= GetAliasedModuleOrModule ( module
);
1006 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
1007 NormalizeFilename ( aliasedModule
.GetPath () ),
1009 OutputInstallTarget ( sourceFilename
,
1011 module
.installBase
);
1017 MingwBackend::GetRegistrySourceFiles ()
1019 return "bootdata" SSEP
"hivecls.inf "
1020 "bootdata" SSEP
"hivedef.inf "
1021 "bootdata" SSEP
"hiveinst.inf "
1022 "bootdata" SSEP
"hivesft.inf "
1023 "bootdata" SSEP
"hivesys.inf";
1027 MingwBackend::GetRegistryTargetFiles ()
1029 string system32ConfigDirectory
= NormalizeFilename (
1030 MingwModuleHandler::PassThruCacheDirectory (
1031 "system32" SSEP
"config" SSEP
,
1032 installDirectory
) );
1033 return system32ConfigDirectory
+ SSEP
"default " +
1034 system32ConfigDirectory
+ SSEP
"sam " +
1035 system32ConfigDirectory
+ SSEP
"security " +
1036 system32ConfigDirectory
+ SSEP
"software " +
1037 system32ConfigDirectory
+ SSEP
"system";
1041 MingwBackend::OutputRegistryInstallTarget ()
1043 string system32ConfigDirectory
= NormalizeFilename (
1044 MingwModuleHandler::PassThruCacheDirectory (
1045 "system32" SSEP
"config" SSEP
,
1046 installDirectory
) );
1048 string registrySourceFiles
= GetRegistrySourceFiles ();
1049 string registryTargetFiles
= GetRegistryTargetFiles ();
1050 fprintf ( fMakefile
,
1051 "install_registry: %s\n",
1052 registryTargetFiles
.c_str () );
1053 fprintf ( fMakefile
,
1054 "%s: %s %s $(MKHIVE_TARGET)\n",
1055 registryTargetFiles
.c_str (),
1056 registrySourceFiles
.c_str (),
1057 system32ConfigDirectory
.c_str () );
1058 fprintf ( fMakefile
,
1059 "\t$(ECHO_MKHIVE)\n" );
1060 fprintf ( fMakefile
,
1061 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"hiveinst.inf\n",
1062 system32ConfigDirectory
.c_str () );
1063 fprintf ( fMakefile
,
1068 MingwBackend::GenerateInstallTarget ()
1070 vector
<string
> vInstallTargetFiles
;
1071 GetInstallTargetFiles ( vInstallTargetFiles
);
1072 string installTargetFiles
= v2s ( vInstallTargetFiles
, 5 );
1073 string registryTargetFiles
= GetRegistryTargetFiles ();
1075 fprintf ( fMakefile
,
1077 installTargetFiles
.c_str (),
1078 registryTargetFiles
.c_str () );
1079 OutputNonModuleInstallTargets ();
1080 OutputModuleInstallTargets ();
1081 OutputRegistryInstallTarget ();
1082 fprintf ( fMakefile
,
1087 MingwBackend::GetModuleTestTargets (
1088 vector
<string
>& out
) const
1090 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
1092 const Module
& module
= *ProjectNode
.modules
[i
];
1093 if ( !module
.enabled
)
1095 if ( module
.type
== Test
)
1096 out
.push_back ( module
.name
);
1101 MingwBackend::GenerateTestTarget ()
1103 vector
<string
> vTestTargets
;
1104 GetModuleTestTargets ( vTestTargets
);
1105 string testTargets
= v2s ( vTestTargets
, 5 );
1107 fprintf ( fMakefile
,
1109 testTargets
.c_str () );
1110 fprintf ( fMakefile
,
1115 MingwBackend::GenerateDirectoryTargets ()
1117 intermediateDirectory
->CreateRule ( fMakefile
, "" );
1118 outputDirectory
->CreateRule ( fMakefile
, "" );
1119 installDirectory
->CreateRule ( fMakefile
, "" );